I did not passed the test while everything seems ok // Functional Programming: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem

Tell us what’s happening:
Hi everyone,
My code below did not passed all the tests. I had an error for the test:

map , filter , or reduce should be used.

But I used a combination of map and filter, so I don’t understand what happened.
Maybe a bug ? Or perhaps I misused Number.isInteger?

Any feedback is welcome
:slight_smile:

Your code so far


const squareList = (arr) => {
// Only change code below this line
return arr
  .filter(x => Number.isInteger(x) && x > 0)
  .map(x => x * x );
// Only change code above this line
};

const squaredIntegers = squareList([4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2]);


Your browser information:

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

Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem

Link to the challenge:

The test is expecting arr and .filter to be on the same line. I think that someone filed a bug for this (not 100% sure though).

2 Likes

Ok, many thanks!
It works well.

For future readers’ reference:

1 Like