-1
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];  const squareList = (arr) => {
  "use strict";
  const squaredIntegers = arr.filter( (num) => num > 0 && num % parseInt(num) === 0 ).map( (num) => Math.pow(num, 2) );
  return squaredIntegers;
};

const squaredIntegers = squareList(realNumberArray); 
console.log(squaredIntegers);
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62

1 Answers1

3

Because one const is a local variable of the squareList function, the other const is a global variable holding a squareList. Using the same variable name twice in different scopes is called shadowing, thats sometimes useful but it can also create confusion like in this case.

Jonas Wilms
  • 132,000
  • 20
  • 149
  • 151