Tell us what’s happening:
I get TypeError: sqrIntegers.push is not a function. Cannot push() method be used in reduce() method?
Your code so far
const squareList = (arr) => {
// Only change code below this line
return arr.reduce((sqrIntegers, num) => {
return Number.isInteger(num) && num > 0
? sqrIntegers.push(num * num)
: sqrIntegers;
}, []);
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Challenge: Functional Programming - Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
Link to the challenge: