Write Higher Order Arrow Functions 4235

Write Higher Order Arrow Functions 4235
0.0 0

#1

What am I doing wrong here?

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) && num > 0).map(Math.pow(num, 2);
  // 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.99 Safari/537.36.

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


#2

why are you filtering out negative numbers?


#3

actually my bad. the challenge says to filter out negative numbers…

hmm, in my solution, I didn’t do the num > 0 part though and I passed the challenge. maybe there is a bug. Were you able to pass it?

oh never mind I see the problem. Your code is not syntactically correct.

The map function takes a callback function which you have not defined properly. Eg .
array.map( (item) => item+=2 );
this is how you define a map for an array that will add 2 to each item in the array
compare that to your map and you will see you are missing the correct function definition


#4

That did it. Thank you very much again.