Tell us what’s happening:
I am stuck on this challenge despite looking at the solution I cant seem to solve the problem, Where could I be going wrong ? I am having the same identical code like with the solutions provided but it does not get the job done kindly I need your help on this guys.
Your code so far
const squareList = (arr) => {
// Only change code below this line
return arr;
const squareList = (arr) => {
const positiveIntegers = arr.filter(num => {
return num >= 0 && Number.isInteger(num);
});
const squaredIntegers = positiveIntegers.map(num => {
return num ** 2;
});
return squaredIntegers;
};
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.
Challenge: Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
Like ieahleen said, your return statement means nothing else inside that function is being executed.
You also have unnecessarily repeated the function definition “squareList” and created an entirely new function inside the outer “squareList” function, making it somewhat confusing to read. So I can understand where you were confused, haha!!
Your inner squareList function looks fine though, so just copy that whole function, move it outside of the “outer” squareList function, and delete that outer one. Then it should work.