+ 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)
4 Answers
+ 1
I don't need to call that function first
+ 1
Just sent a reply on your new question Anshif :)
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.
0
Allan can you answer to my another question