Hello,
I am a newbie to programming and please be patient in helping me. So I am trying to code this challenging project. I don’t want to copy and paste on what others did but wanted to try myself. I couldn’t figure out what I am doing wrong below. Per the instructions, I tried but not going anywhere. Could someone help me with this?
// Add your functions below:
const validateCred = card => {
let checkCard = card.splice(-1);
let newArr = card.reverse();
console.log(newArr);
for(let i =0; i<newArr.length; i++){
if(i % 2 === 0){
newArr[i] = newArr[i] * 2;
if (newArr[i] > 10){
newArr[i] = newArr[i] - 9;
return newArr[i];
}
}
}
}
console.log(validateCred(valid3));
The output is
[ 3, 2, 5, 8, 9, 9, 1, 0, 2, 1, 6, 1, 7, 3 ]
9
Could someone tell me what is not looping the array?
Thanks
> Blockquote