i need help on returning new array containing squares
const squareList = arr => {
// Only change code below this line
return arr.filter(y => Number.isInteger(y) && y > 0);
arr.map(y => y * y )
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers)
You need a return statement somewhere. But if you return before you square the numbers, then you’ll never square the numbers… That’s how return statements work.
The challenge is asking you to both remove certain elements and square the rest. You need to use the output from your filter and reduce to accomplish this.