Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Add your functions below:
  2. function validateCred(numArr) {
  3.   let total = 0;
  4.   for (let i = numArr.length - 1; i >= 0; i--) {
  5.     let currValue = numArr[i]
  6.     if ((numArr.length - 1 - i) % 2 === 1) {
  7.       currValue *= 2;
  8.       if (currValue > 9) {
  9.         currValue -= 9;
  10.       }
  11.     }
  12.     total += currValue;
  13.   }
  14.  
  15.   return total % 10 === 0;
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement