+ 1

Why this code isn't working?

var years = (1990, 1457, 1976); function arrayCalc(arr, fn) { var arrRes = []; for (var i = 0; i < arr.length; i++) { arrRes.push(fn(arr[i])) } return arrRes; }; function calculateAge (el) { return 2018 - el; } var ages = arrayCalc(years, calculateAge); console.log(ages)

21st Jan 2018, 11:26 AM
ANSHIF BABU AS
4 Answers
+ 1
I don't need to call that function first
21st Jan 2018, 12:21 PM
ANSHIF BABU AS
+ 1
Just sent a reply on your new question Anshif :)
30th Jan 2018, 6:24 AM
HazeDev
0
You have to change your years variable to an array or work out a way to convert it to an array in your script. It can not be iterated over using indexing in its current state.
21st Jan 2018, 12:48 PM
HazeDev
0
Allan can you answer to my another question
29th Jan 2018, 4:45 PM
ANSHIF BABU AS