Tell us what’s happening:
I am lost on how this code was written.
This is what i have so far:
- const realNumberArray variable that has an array of numbers
- A function expression squareList that gets assigned the function call with a param/argument of arr.
- in the function there is a const variable squaredIntegers that is equal to the code we are going to write to solve the problem (or at least equal to what we are going to return to it).
- return squaredIntegers to the variable. This gets returned to arr then to squareList.
testing the code there is a const squaredIntegers variable that is in the function from #2. This is set to equal the variable that is refrenceing the function and it gets passed the realNumberArray.
What i am confused on is the test. How can you create a variable that is in an already created function that is set to equal the variable that is referencing the function its in.
Literally my mind is blown.
Your code so far
const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];
const squareList = (arr) => {
"use strict";
// change code below this line
[spoiler]
const squaredIntegers = realNumberArray.filter(realNumberArray=>realNumberArray%1===0);
console.log(squaredIntegers);
[/spoiler]
// change code above this line
return squaredIntegers;
};
// test your code
const squaredIntegers = squareList(realNumberArray);
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/67.0.3396.87 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/write-higher-order-arrow-functions