Write Higher Order Arrow Functions - can't figure out how to exclude the decimal numbers

Tell us what’s happening:
I am struggling to understand how to chain the arrow functions (if indeed that’s what i’m supposed to be doing) so that I can exclude the decimal numbers from my new array.

I’ve tried getting "Number.isInteger(arr)" or "Number.isInteger(x)" (where x is defined) but I don’t know if this is the right approach and I also don’t know how I’m supposed to add it to my code already.

I’ve seen the solution and it’s quite different to mine. I’m at the point where I’m squaring only the positive numbers, but I can’t get it to only do the integers.

I’m sure this is insanely obvious to most people but I’ve been sitting here for an hour and a bit trying different combos. I was trying parseInt(x, 10) or parseInt(num, 10) for a long while to no avail, and I did Math.round to even less avail.

Thanks in advance for your help.

Your code so far


const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
  "use strict";
  // change code below this line
  const squaredIntegers = arr.filter (x => x > 0).map(x => x * x);
    // change code above this line
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
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/73.0.3683.103 Safari/537.36.

Filter needs for you to return true or false from the callback, you already have a condition in there, you can chain an other one using the AND operator, &&.

You can use the isInteger method or other approaches
Example: Math.round(x) === x this return true if x is whole, and false if it isn’t , find an other way!

Thankyou so much for your help @ILM . I really struggled with this and it’s taken me about 2 hours to nut it out but I’m actually really happy with it.
This is what I ended up with const squaredIntegers = arr.filter(x => x > 0 && Math.round(x) === x).map(x => x * x);

Awesome! I suggest for practice you find a different way than this, as this was my example

const squaredIntegers = arr.filter(x => x > 0 && parseInt(x) === x).map(x => x * x);