0
57.3 Salary Rise
Hi there What would the proper code with the for.each function be? Thanks function main() { var percent = parseInt(readLine(),10); var salaries = [3000, 7000, 5000, 15000]; let sum = 0; for (let i = 0; i < salaries.length; i++) { sum += salaries[i]; } console.log (sum * percent / 100) }
2 Answers
+ 4
salaries.forEach(i=>sum+=i);
+ 1
sum=0
for (let i of salaries)
sum += i;
Do you mean about this?