Write Higher Order Arrow Functions ? num is not defined

Tell us what’s happening:

Your code so far


const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
  "use strict";
const squaredIntegers = arr.filter ( (num) > 0 && num % parseInt(num) === 0).map( (num) => Math.pow(num,2));
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:63.0) Gecko/20100101 Firefox/63.0.

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

Filter receives a callback as parameter, try this:

const squaredIntegers = arr.filter ( (num) => num > 0 && num % parseInt(num) === 0).map( (num) => Math.pow(num,2));
  return squaredIntegers;
};

You are passing (num) > 0 && num % parseInt(num) === 0 instead the callback :slight_smile:

You can read more about filter here -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

:relieved: Thanks for pointing that out.

1 Like

Your welcome :wink:

It’s a good practice to close your question marking the post as the answer, then others will now that it’s solved :slight_smile:

See ya and keep coding!