I have created a code to determine the highest scoring word as a string, however when I calculate all words and attempt to display the results, I am encountering an issue where all results are showing as: NaN
function high(x) {
var words = x.split(' ');
var y;
var num = [];
for (var i = 0; i < words.length; i++) {
y = words[i].split('');
for (var d = 0; d < words[i].length; d++) {
if (y[d] == 'a') num[i] += 1;
else if (y[d] == 'b') num[i] += 2;
...
// Similar conditional statements for letters up to 'z'
...
else num[i] += 26;
}
}
console.log(...num);
}
high("what time are we climbing up the volcano");