Math squaring. hints dont even work

Tell us what’s happening:

i dont know how to solve this one

Your code so far

const squareList = arr => {
// Only change code below this line
return arr.filter(num => num > 0 && num % parseInt(num)).map(num => Math.pow(num, 2));
// Only change code above this line

const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem

Link to the challenge:

arr = arr.filter(number => number > 0 && Number.isInteger(number)).map(number => number * number)

You’re almost there. Your test for whether the number is an integer is not quite right.

num % parseInt(num)

parseInt returns just the integer part of the number and then you are using the modulus operator with the original. What should the modulus operator return if both sides of the equation are the same? How would that return value work in an if statement?

1 Like

Better to just give a hint and help them figure it out then to just give the answer.

1 Like