0
[SOLVED]How to do calculation in array of objects
I want to do calculation in this all calc object. how to do that? https://code.sololearn.com/WA0Rt2FK4IJl/?ref=app
8 ответов
+ 2
What does the code supposed to do? maybe someone can help if you could describe your intention more clearly, maybe with an example of output expected from the code.
+ 1
Ipang actually i already solved it
+ 1
Good job! 👍,
Can you please mark it by adding [SOLVED] in the question. It helps people understand that it had been solved ...
+ 1
I'll do that
+ 1
EsaKurniawan,
How did you solve it? using reduce() or some other way?
+ 1
i did it like this:
useEffect(() => {
debt.length && setTotal(eval(`${total} ${debt.at(-1).calc}`).toString())
}, [debt])
+ 1
This is in react.js actually because sololearn doesn't have react.js so i convert the equation to JavaScript
+ 1
/ * === == = are some coding tools you can use in creating your calculator