'X is not defined' error

I’m doing the ES6 JS challenges and I’m at the “Higher Order Arrow Functions” challenge. The code I’m using to solve this is:

const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2];

const squareList = (arr) => {
  "use strict";
  // This is my solution
  const squaredIntegers = (arr.filter(x => x > 0 && x % parseInt(x) === 0)).map(x => x*x);
  // End of solution
  return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
console.log(squaredIntegers);

But it prints a message saying ‘x is not defined’, even though I saw that the MDN docs had similar usage and did not define variables in anonymous functions… What’s the right way to define these variables then? I know I can solve this by defining x using let/var in the function scope of squareList, but then how is MDN showing examples which are innacurate?

Hello check, array.prototype.filter(). in you case it is (arr.filter).

Hope this hint helps to solve it.

There’s nothing wrong with the code you wrote. Try clearing your browser cache - the tests run fine for me.

Note you don’t need the extra set of parentheses around the filter function - it won’t do anything bad, you’re just telling JS to execute something, which it is already doing anyway.

I figured out the problem, since 'use strict' is given, I can’t use undefined variables in the code. Whereas the MDN Docs did not have this directive in their example code, so they got away without defining their in-function use of x.

You don’t have any undefined variables and neither do MDN, it has nothing to do with that.

Well, removing the ‘use strict’ directive solved the problem so I don’t know what else could be happening.

What browser are you using?

I’m using Chrome, the latest version (69+). However, the issue is not with my code, but with the cache or something as DanCouper suggested. I reset the challenge and it now works without modification to the ‘use strict’ directive. Seems to be a fluke or some sort.