Checking if the number is Integer in Use Higher-Order Functions map, filter, or reduce

Hello Guys, this is my first time posting something in FCC forum.
I just want to check if its ok to use the following code to check if the number is Integer. When I worked out the solution myself I couldn’t remember the method isInteger()

  Thats my code so far
const squareList = arr => {
 let newArray= arr
 .filter(num => num - Math.floor(num) === 0 && num > 0).map(num => num * num)
return newArray

const squaredIntegers = squareList([4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2]);

   **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36

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

Link to the challenge:

I belive this is right. There are multiple methods to solve a problem.
In your method you are using all these filter and map which maybe create hinderance for time complexity otherwise you are good to go.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.