have included comments in below code to explain problem
The solution i have works but i don’t understand why the first attempt, as shown , does not.
**Your code so far**
const squareList = arr => {
const arrPosInt=arr.filter(elem=>{
if(Number.isInteger(elem) && elem>0) {
return elem*elem} //includes square function/statement, but....
})
console.log(arrPosInt) //....doesn't work. returns [ 5, 3 ]
//return arrPosInt; // ..returns [ 5, 3 ]
const arrPosIntSq = arrPosInt.map(elem=>elem*elem) //have to square seperately..
return arrPosIntSq; // ..returns [ 25, 9 ]
};
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/93.0.4577.63 Safari/537.36
Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
Link to the challenge: