Functional Programming - Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem

This worked, but not until I changed the line

  return filteredNum^2;

to

  return filteredNum*=filteredNum;

Why does the x^2 not work in place of x*x?

  **Your code so far**
const squareList = arr => {
// Only change code below this line
let result=[];
result = arr.filter(checkNum);

function checkNum(num) {
return num > 0  && num*10 % 10==0;
}

let squaredIntegers=[];
squaredIntegers= result.map(sqNum);

function sqNum(filteredNum){
return filteredNum*=filteredNum;
}
//console.log(result);
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/104.0.0.0 Safari/537.36

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

Link to the challenge:

Note, there is no reason to have the = in there.

You are looking for **

The carrot does something else

Thx. Hey are you a FreeCodeCamp employee or are you just a good guy/volunteer?

Oh, I’m a volunteer. I hang out and answer questions when I’ve got time.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.