Write Higher Order Arrow Functions - Doesn't filter return an array?

Write Higher Order Arrow Functions - Doesn't filter return an array?


Tell us what’s happening:
I can’t see where I’m doing wrong. When I try to test the code, I get "squaredIntegers should be an array, and squaredIntegers should be [16, 1764, 36]. I also get (in the console area) Cannot read property ‘0’ of undefined which, I assume refers to the first index of the nonexistent squaredItnegers array.

Since filter returns an array, and squaredIntegers is set to filter then map, shouldn’t it be an array?

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) => num>0 && num % parseInt(num) === 0 ).map( (num) => Math.pow(num, 2) );
      return squaredIntegers;
// change code above this line
  return squaredIntegers;
// test your code
    const squaredIntegers = squareList(realNumberArray);

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:


NEVER MIND… Dumb move on my part. I returned squaredIntegers twice


I realize you got your solution to work, but your filter could be simplified by:

arr.filter(num => num > 0 && num === parseInt(num))