Write Higher Order Arrow Functions helps

Write Higher Order Arrow Functions helps
0

#1

Tell us what’s happening:
I have found the integer numbers .filter((x => x > 0 && x % 2 ===0)) but I need help to square them.

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

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


#2

arr.filter returns an array: this allow you to ‘concatenate’ other HighOrderFunctions.
Something like: arr.filter( x => stuffOnX).map(y => stuffOnY) will operate stuffOnY for each element of the array returned from the first filter function^^

Good luck! :slight_smile:


#3

Your filter has not filtered all positive integers. It has only filtered positive even integers. You want all positive integers. After you to do, then you can use the map method to iterate over those filtered numbers and square them. How do you square a number? You multiple it by itself.


#4

Thank you :rose: so much I have done it