Write Higher Order Arrow Functions helpp

Okay it fetches the right answer for me but doesnt strict equal check if the values are the same too?
i mean x^0 would be 1 and ex could be 6 or 14 and then i checked (x^0) === x so typewise it matches but valuewise it doesnt so how did i clear?

Your code so far

const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
  "use strict";
  const squaredIntegers = arr.filter(x=>(x^0)===x).map(x=>x*x);
return squaredIntegers;
// test your code
const squaredIntegers = squareList(realNumberArray);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:

Your code does error because you can not redefine squaredIntegers because it was declared via const keyword. If you look at your browser’s console (Ctrl+Shft+J in Chrome), you can see the error.

Deleting the first line will prevent this error.

Also, your squareList function is not explicitly returning a value, so by default undefined is returned.

sorry actually i came back to the test and sent over the code.i made the edits so that it gives the correct answer.please explain how did the filter function work

You wrote the code, so why do you think the filter function works?

Did you copy the code without knowing exactly what it was doing?

x^0 is not 1 usually, as ^ is not the power operator

^ is the bitwise OR operation, which in js also had the side effect of coercion into a 32 bit signed integer

It’s a neat trick to compare that result to the value itself to check if it’s an integer, but it’s not entirely robust (fails e.g. when x is larger than a 32 bit int) and relatively pointless when we have Number.isInteger

Number.isInteger is a function to check if it is an int?I copied the code thinking that its a power operator

hi Hamzah, it is easy to check what Number.isInteger does. Just google it and then you will get multiple hits from google including the MDN specification for this function (which describes it in full).

Get into the habit of googling things that are well known (like what does this function do) because it is a part of your everyday life as a software developer.