Write Higher Order Arrow Functions yy

Write Higher Order Arrow Functions yy
0

#1

Tell us what’s happening:

please what is wrong with this code

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.filter((num) => Number.isInteger(num));
  
 const squaredIntegers = squaredIntegers.map((square) => square*square);
  // 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/65.0.3325.181 Chrome/65.0.3325.181 Safari/537.36.

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


Write Higher Order Arrow Functions yyy
#2

Well without the context i am not too sure but you are assigning multiple things to the constant squaredIntegers, which does not seem right


#3

Tell us what’s happening:

i cannot still pass this lesson with this

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.filter((num) => Number.isInteger(num));
  const squaredIntegers=squaredIntegers.map(square =>square*square);
  
  
  // 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/65.0.3325.181 Chrome/65.0.3325.181 Safari/537.36.

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


#4

Try console.log()ing your code and you might just find out your mistake.


#5

You can’t reassign a new value to a constant, like you’re doing by assigning squaredIntegers.map(...) to squaredIntegers.

However you can chain filter and map calls, like arr.filter(...).map(...), and assign the whole thing to squaredIntegers


#6

you don’t put a filter condition over there
it will ben like
return num>0 && num%1==0;