Credit card checker

Hey,

I’ve tried to build a credit card checker.
for some reason inside a function, I’m trying to use an array to update but I do not seem to understand why it isn’t updating.
the link for the exercise: https://www.codecademy.com/practice/projects/credit-card-checker

array name that not responding inside the function is: checkSum

function validateCred(val)  {
  
  let checkSum =[];
  let arrayReverse = val.reverse();
  let count = 1;
  let summingNumber = 0;
  let divideNumber = [];

  
  
for ( i = 1; i < arrayReverse.length+1; i++){
  if (i % 2 === 0){
  let a = arrayReverse[i]*2;
     if (a > 9) {
       b = splitToDigit(a);
       a = b[0] + b[1];
   **cehckSum.push(a);**  
    }else { 
  **cehckSum.push(arrayReverse[i]);**
     }}else  {
  **cehckSum.push(arrayReverse[i]);**
}}
console.log('this is the checksum before it is check valid or not' + checkSum);
for (j=0; j < checkSum.length; j++){
  summingNumber = summingNumber + checkSum[j];
}
if (summingNumber % 10 === 0 ){
  console.log ('The card number is valid.');
}else {
  console.log ('The card number is invalid.');
}}

Spelling.

2 Likes

@arc3888812183, did that solve your problem ?

Yes
Thanks
It did solved my problem