Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. for (let k = 0; k < n; k++) {
  2. const word = gets().toLowerCase();
  3. for (let i = 0; i < word.length; i++) {
  4. currWeight += word.charCodeAt(i) - 96;
  5. }
  6. if (currWeight > maxWeight) {
  7. maxWeight = currWeight;
  8. heaviestWord = word;
  9. }
  10. currWeight = 0;
  11. }
  12. print(`${maxWeight} ${heaviestWord}`);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement