let validateCred = array => {
let sumArray = [];
let summed = array.reduceRight(sum, currentValue, index) => {
if(index === array.length - 1) {
sum = currentValue;
} else if (index%2 !== 0) {
const s = currentValue * 2;
sum += s > 9 ? s - 9 : s
} else {
sum += currentValue
}
return sum
}, 0)
//console.log(summed)
if (summed%10 === 0) {
return true;
} else {
return false;
}
}
this will then turn the error;
let summed = array.reduceRight(sum, currentValue, index) => {
^
SyntaxError: Unexpected token .
Does anyone have an explanation? (the error pointing towards the dot in the array . reduceRight