Hi friends, my solution to this challenge is basically the same as the one in the provided solution (in my opinion). Only the if condition is written differently. Why does my code give the error “cannot read concat property of undefined”?
I’m sure the problem is simple but I can’t seem to figure it out. If you can point me to a direction, I will really appreciate it!
**Your code so far**
const squareList = arr => {
return arr.reduce((squares,item)=>{
if (Number.isInteger(item) && item>0)
{squares.concat(item*item)}
},[])
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36
Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
Link to the challenge: