Write Higher Order Arrow Functions help

Write Higher Order Arrow Functions help
0.0 0

#1

Tell us what’s happening:

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;**
**  const squaredIntegers = arr.filter(num => Number.isInteger(num) && num>0);**
**  const squaredIntegers= arr.map(num  => num*num);**
**  // 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36.

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


#2

can anybody tell me whats the problem in this code?


#3

You can’t reassign a new value to squaredIntegers because it’s declared with the const keyword. What you can do however is to chain the filter and map calls, like

const squaredIntegers = arr.filter(...).map(...);

#4

ok thank you so much, let me try this


#5
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
  return arr.
            filter((num) => Number.isInteger(num)).
            map((num) => num * num);
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);