unfortunately after several months later the solution to this code does not work anymore
why because maybe they updated the challenge
originally(i mean months ago) the first variable looks like this
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
but now they added the -2 at the end of the array
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
"use strict";
// below this line is the old solution!!!!!!!!!!!!!
const squaredIntegers = arr.filter(num => Number.isInteger(num)).map(square => square * square)
// change code above this line
return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);
for this code to work, what i did is just delete that -2 in realNumberArray
since the test said squaredIntegers
should be [16, 1764, 36]
and i passed all the test!
if you dont remove the -2 it will log like this [16, 1764, 36, 4] which will fail
my question is did i just cheat?
because im feeling like something is missing