I have figured out how to calculate the value of numbers from a single string, using as an example..
var sum = \"13-2-10-7-3\".split(\'-\').reduce(function(x, y)
Loop over the credit card numbers and check if sum is max store it and continue to loop and store the maximum credit card number and return it:
function max_credit_sum(arr){
max = -1
credit_card = ''
for(ele of arr){
numbers = ele.replace(/-/g, '').split('')
sum = 0
for(num of numbers){
sum += parseInt(num)
}
if(sum >= max){
credit_card = ele
max = sum
}
}
return credit_card
}
// Test
arr = ['4916-2600-1804-0530', '4779-252888-3972', '4252-278893-7978', '4556-4242-9283-2260']
maximum = max_credit_sum(arr)