Advertisement
bai_onzi

Mock 5 / heaviestWord

Mar 7th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let input = ['5',
  2. 'telerik',
  3. 'alpha',
  4. 'java',
  5. 'Spring',
  6. 'nodeJS'];
  7.  
  8.  
  9. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  10.  
  11. let alphabet = "0abcdefghijklmnopqrstuvwxyz".split('');
  12.  
  13. let wordsCount = +gets();
  14. let sum = 0;
  15. let wordWeight = 0;
  16.  
  17.  
  18. for(let i = 0; i < wordsCount; i++){
  19.     let word = gets().toLowerCase();
  20.     let wordArr = word.split('');
  21.     // console.log(wordArr);
  22.     let weight = alphabet.indexOf(wordArr[i] + '');
  23.     sum += weight;
  24.     console.log(sum + word)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement