Tell us what’s happening:
Describe your issue in detail here.
Hello everyone I need to know Why my code did not pass. I’ve use map filter and reduce. map and filter work properly but reduce did not work. i want it to do the square of the items in the array. someone can help me
Your code so far
const squareList = arr => {
// Only change code below this line
return arr.filter((a)=>{return a>0}).filter((a)=>{return Number.isInteger(a)}).reduce((arr,b)=>{return arr.push(b*b)},[]);
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
const squareList = arr => {
// Only change code below this line
return arr.filter((a)=>{return a>0}).filter((a)=>{return Number.isInteger(a)}).reduce((arr,b)=>{return arr.push(b*b)},[]);
// 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 (X11; Ubuntu; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0
Challenge: Functional Programming - Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
[quote=“kaghenimbale, post:1, topic:563583”][quote=“kaghenimbale, post:1, topic:563583, full:true”] Tell us what’s happening:
Describe your issue in detail here.
Hello everyone I need to know Why my code did not pass. I’ve use map filter and reduce. map and filter work properly but reduce did not work. i want it to do the square of the items in the array. someone can help me
Your code so far
const squareList = arr => {
// Only change code below this line
return arr.filter((a)=>{return a>0}).filter((a)=>{return Number.isInteger(a)}).reduce((arr,b)=>{return arr.push(b*b)},[]);
// Only change code above this line
};
const squaredIntegers = squareList([-3, 4.8, 5, 3, -3.2]);
console.log(squaredIntegers);
const squareList = arr => {
// Only change code below this line
return arr.filter((a)=>{return a>0}).filter((a)=>{return Number.isInteger(a)}).reduce((arr,b)=>{return arr.push(b*b)},[]);
// 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 (X11; Ubuntu; Linux x86_64; rv:105.0) Gecko/20100101 Firefox/105.0
Challenge: Functional Programming - Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem