Skip to content
Advertisement

How to calculate sum of values stored in getter?

I want to be able to calculate the sum of the int values stored in my getter method. So basically what I want the program to do is to sum the total hours of all the workers into one number. I have no idea how to do this…

The output I get with this code is just the hours for all the workers but not calculated into one sum.

JavaScript

Advertisement

Answer

JavaScript

All you need to do is run a for loop, get each employee hour and add it in the total then display the total_Hours variable.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement