07. Name Wars
Molia za pomosht
function nameWars(input) {
let name = input.shift();
let current = 0;
let max = 0;
let namemax = "";
let max1 = Number.MIN_SAFE_INTEGER;
while(true){
if (name == "STOP") {
break;
for (let i = 0; i < name.length; i++) {
current = current + name.charCodeAt(i);
if (current > max1 && current>max){
max = current;
namemax = name;
current = 0;
}
}
}
console.log(`Winner is ${namemax} - ${max}!`);
}
}