Can someone assist me with pushing even numbers into an array using an arrow function? I'm unsure of how to do this.
Here's my code:
var arrayEvenNumbers = [];
var evenNumbers = (arrayEvenNumbers) => {
for (i = 2; i <= 20; i++) {
if (i % 2 == 0) {
arrayEvenNumbers.push(i);
}
}
}
console.log(evenNumbers(arrayEvenNumbers));
I am a beginner and learning as I go, so any help is appreciated. Thank you!
Note: My English may not be perfect as it is not my first language.