# Write Higher Order Arrow Functions(Why this code is not valid?)

Write Higher Order Arrow Functions(Why this code is not valid?)
0

#1

Tell us what’s happening:

``````
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.map((num)=>{
if(Number.isInteger(num)){
num*num;
}
})
// change code above this line
return squaredIntegers;
};
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3452.0 Safari/537.36`.

[Another solutions?] ES6: Write Higher Order Arrow Functions
#2

Try this code.
// change code below this line

`````` const squaredIntegers = [];
arr.map((num)=>{
if(Number.isInteger(num)){
squaredIntegers.push(num*num);
}
})
``````

// change code above this line
return squaredIntegers;

#3

Thanks for answer but I want to ask, whats wrong with the my solution, as map itself returns an array, if possible explain

#4

There are two main problems with your original solution. Answer the following questions, and you’ll probably figure out what the problems are:

1. For each value your arrow function deals with, what value does it return? [Use console.log() to check this.]
2. At the end of the day, how many items should there be in the squaredIntegers array? How many are in the array that your code returns?