[SOLVED]How to do calculation in array of objects | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

28th Dec 2021, 7:05 AM
EsaKurniawan
8 Answers
+ 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.
28th Dec 2021, 8:17 AM
Ipang
+ 1
Ipang actually i already solved it
28th Dec 2021, 8:29 AM
EsaKurniawan
+ 1
Good job! 👍, Can you please mark it by adding [SOLVED] in the question. It helps people understand that it had been solved ...
28th Dec 2021, 8:32 AM
Ipang
+ 1
I'll do that
28th Dec 2021, 8:35 AM
EsaKurniawan
+ 1
EsaKurniawan, How did you solve it? using reduce() or some other way?
28th Dec 2021, 9:12 AM
Ipang
+ 1
i did it like this: useEffect(() => { debt.length && setTotal(eval(`${total} ${debt.at(-1).calc}`).toString()) }, [debt])
28th Dec 2021, 9:20 AM
EsaKurniawan
+ 1
This is in react.js actually because sololearn doesn't have react.js so i convert the equation to JavaScript
28th Dec 2021, 9:22 AM
EsaKurniawan
+ 1
/ * === == = are some coding tools you can use in creating your calculator
29th Dec 2021, 1:36 AM
MAX Comic Tv