Tell us what’s happening:
Hello,
In this challenge, I decided to use filter and map functions to solve.
The filter function checks for any element greater than zero, and is an integer,
While map, squares anything that passed the filter function.
The issue is happening somewhere in the filter function where any element
being passed…passes, while nothing else is being passed to the map function
and nothing is being returned at the function.
Your code so far
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];
const squareList = (arr) => {
"use strict";
// change code below this line
const squaredIntegers = arr
.filter((item) => {
item > 0 && parseInt(item)
console.log(item)
}).map((item) => {
item => item * item
})
console.log(squaredIntegers)
// test your code
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; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-higher-order-arrow-functions