0
57.3 Practice Salary increase
Hello everyone, Can someone find the error on the following code? While i get the correct result , it returns also an undefined entry and i don't know why. 1500 undefined The code is here: function main() { var percent = parseInt(readLine(),10); console.log(salaryIncrease(percent)); } var salaries = [3000, 7000, 5000, 15000]; const salaryIncrease = percent => { //your code goes here let salary=0; salaries.forEach(budget => { budget=budget*percent/100; salary=salary+budget; }) console.log(salary); } Thanks in advance for your help.
2 odpowiedzi
0
i found another post where instead of console.log he used return and my code is successful now . I don't understand though why console.log returns and undefined entry apart from the correct result:
https://www.sololearn.com/Discuss/2901093/javascript-57-3-practice-salary-rise
0
Because the console.log in the main function get nothing for its function‘s parameter.
That means you should first observe / note how will be called the salaryIncrease function. For this reason this function should return a value.