Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Add your functions below:
- function validateCred(numArr) {
- let total = 0;
- for (let i = numArr.length - 1; i >= 0; i--) {
- let currValue = numArr[i]
- if ((numArr.length - 1 - i) % 2 === 1) {
- currValue *= 2;
- if (currValue > 9) {
- currValue -= 9;
- }
- }
- total += currValue;
- }
- return total % 10 === 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement