Hola, quería saber si podrían ayudarme con este ejercicio usando reduce()
:
Quisiera saber por qué usando el operador ternario si funciona correctamente, pero usando if me aparece este error.
const squareList = arr => {
// Only change code below this line
return arr.reduce((sqrIntegers, num) => {
if (Number.isInteger(num) && num > 0) {
sqrIntegers.concat(Math.pow(num, 2))
}
}, []);
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
**TypeError: Cannot read property 'concat' of undefined**
Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
Link to the challenge: