# Write Higher Order Arrow Functions //

Tell us what’s happening:
I’m trying yo find out the difference between filter, reduce and map. somehow it’s a bit vague.

what am I missing to pass the problem here?

``````
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr.filter(Math.floor(arr)=>0 ^2);

// change code above this line
return squaredIntegers;
};
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);
``````

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15`.

filter expects an input function which returns true or false. If it returns true, the element gets added to the returned array.

map goes through each element one at a time and applied whatever function you want to it (doesn’t have to return true or false and map doesn’t do anything other than what your input function does) , that is, if your function does nothing, then map just gives back an array of nothing (undefined).

reduce goes through the array and accumulates a value which is returned at the end (based on what your passed in function does to the array values).

Do you think you are using the filter method correctly?

1 Like

Obviously not. I think I need to pick the integers no fractions and square them, that’s what is missing I believe!

``````const squaredIntegers = arr.filter(arr=>arr>0)
``````

I think you are just checking to see if something is greater than 0 which is not the same thing as the value being an integer.

Look up (on google or directly on MDN) the function isInteger and see if that may be useful for you.

1 Like