-1
Write a function that, by receiving an N number as a parameter, returns the N first even numbers (for example, if N is 3, you must print 0, 2 and 4; if N is 5, it must return 0, 2, 4, 6 and 8).
function retornaNNumerosPares(n) {
let numerosPares = [];
for (let i = 0; i < n; i++) {
if (i % 2 == 0) {
numerosPares.push(i)
}
}
return numerosPares;
}
retornaNNumerosPares(5)
It stops at 2, 4 does not enter the array.
https://ideone.com/AdOcis
– hkotsubo