Write Higher Order Arrow Functions help please

This really hard for me to understand so if anyone can help please respond.
I had code in there but i lost it and its wrong anyway.


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;
  // 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 6.1; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0.

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

1 Like

So you have a set of numbers (arr) and you need to loop through them. You are going to return a new array (squaredIntegers). If the number is an integer, square it and it goes in the new array.

filter takes an array and returns a new array with some values filtered (by running a function on every value that returns true to keep or false to drop) – this may help transforming the collection of mixed numbers into a collection of integers.

map takes an array and returns a new array where a function has been ran on every value – this may help squaring each number in your collection of integers.

1 Like

your explanation is so much clearer. now i can code.

2 Likes