+ 2
[Solved]What's the way to get the sum of all salaries in the object?
9 Answers
+ 3
Recursion for the save.
@Ipang, I was of the same mind.
https://code.sololearn.com/WgHj8b1zrMEE/?ref=app
+ 2
I managed to collect and sum employees' salary and group the results by division using recursion.
https://code.sololearn.com/Wef7hk53KxKA/?ref=app
+ 2
Thank you all for the contribution, recursion saves the day, I need to go learn it and how to use it.
+ 1
Justice check the code now, I provided pseudocode
+ 1
Jay Matthews it does gives me the result, but I want something that loops through all and give me a single result
+ 1
Muhammad Awwal Yusuf I believe because you're mixing several different data structures, it's not really feasible. Nesting data structures in different orders and level amounts is going to require you to use more loops to get what you want.
I will say though that you can just use one result variable instead of having multiple for the different job types. You want to preserve the space you have since you're using memory hungry data structures. And each new variable you create takes up more space.
0
Do you have an attempt where have tried already? It can be just pseudocode as well.
0
I could only get into each of the object keys 'salary' . Let me edit the code so you see
0
Sure let us know when you do. Also, just as a tip, but you might want to put your code in a Node.js code bit rather than a web, since you're focusing solely on Javascript.