9 Answers
New Answerhttps://code.sololearn.com/W85HRw2fqUbz/?ref=app
6/27/2022 10:10:14 PM
Muhammad Awwal Yusuf9 Answers
New AnswerI managed to collect and sum employees' salary and group the results by division using recursion. https://code.sololearn.com/Wef7hk53KxKA/?ref=app
Recursion for the save. @Ipang, I was of the same mind. https://code.sololearn.com/WgHj8b1zrMEE/?ref=app
Thank you all for the contribution, recursion saves the day, I need to go learn it and how to use it.
Jay Matthews it does gives me the result, but I want something that loops through all and give me a single result
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.
I could only get into each of the object keys 'salary' . Let me edit the code so you see
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.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message