Despite thoroughly reading the documentation on the map method, I am still unable to make this code work. My objective is to use map to calculate the average of each pair of numbers in an array. Can someone please help me understand what's going wrong?
function getAverage(num1,num2){return Math.ceil((num1+num2)/2)};
function calculateAverages(input){ var result = input.map(getAverage(num1,num2)); return result; }
calculateAverages([1,2,3,4]) // error num1 is not defined
// expected [2,4]