Write a JavaScript program that return an array containing only even numbers between 1 and n.
function generateEvenNums(n) {
let evenNums = [];
for(let i = 2; i <= n; i += 2) {
evenNums.push(i);
}
return evenNums;
}
console.log(generateEvenNums(20));