JavaScript is still very new to me and I'm facing a challenge:
I have an array containing three phone numbers, and I need to calculate the sum of the digits in each phone number string.
I want to find and return the phone number with the highest sum of digits.
I'm feeling a bit embarrassed because my knowledge of JavaScript is quite limited. However, I am determined to learn more and have plans to enroll in a school program this fall. So far, I've covered functions, for loops, and while loops.
var numbers = ["111-222-3333", "333-444-5555", "959-232-8484"]
I understand that my approach is incorrect, but this is all I know for now. Can someone please guide me on how to solve this?
var total = 0;
for(var i = 0; i < numbers.length; i++){
total = total + Number(numbers[i]);
}
alert(total);