Write-higher-order-arrow-functions!

Write-higher-order-arrow-functions!
0.0 0

#1

Tell us what’s happening:
I get square of all number from array.
I want to only square Integer
How can I to choose the Integer number from array. With out about float: 5.6, - 9.8 …etc

Your code so far


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(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; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-higher-order-arrow-functions


#2

Maybe you want to use .filter()


#3

thank! I get it,
I use filter( ) to find integer then map it as square


#4

can you show me your code


#5

Not sure if you’re still on this – but I found you can chain .map() and .filter() to find the solution, where the .filter() logic needs to return the positive integers [4, 42, 6].