Added tests for new date snippets

This commit is contained in:
Angelos Chalaris
2018-09-29 14:29:56 +03:00
parent e8d4ad78d9
commit 29bd1d0a3c
20 changed files with 96 additions and 10 deletions

View File

@ -4,7 +4,7 @@ const luhnCheck = num => {
.reverse()
.map(x => parseInt(x));
let lastDigit = arr.splice(0, 1)[0];
let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + ((val * 2) % 9) || 9), 0);
let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + (val * 2) % 9 || 9), 0);
sum += lastDigit;
return sum % 10 === 0;
};