https://www.codecademy.com/practice/projects/credit-card-checker
I created a function to iterate backwards through an array and it works, but it keeps returning undefined before and after. Why?
const invalid5 = [5, 3, 8, 2, 0, 1, 9, 7, 7, 2, 8, 8, 3, 8, 5, 4];
function validateCred(array){
let num = array.length;
for (let i = num; i >= 0; i--){
console.log(array[i]);
}
}
console.log(validateCred(invalid5));
The output is then:
undefined
4
5
8
3
8
8
2
7
7
9
1
0
2
8
3
5
undefined