Write-higher-order-arrow-functions!

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

Maybe you want to use .filter()

2 Likes

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

can you show me your code

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].