Mitsanski

07.Vowels Sum

Nov 25th, 2021
462
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let sum = 0;
  3.     let text = input[0];
  4.     for (let i = 0; i < text.length; i++) {
  5.         switch (text.charAt(i)) {
  6.             case 'a': sum += 1; break;
  7.             case 'e': sum += 2; break;
  8.             case 'i': sum += 3; break;
  9.             case 'o': sum += 4; break;
  10.             case 'u': sum += 5; break;
  11.  
  12.         }
  13.     }
  14.     console.log("Vowels sum = " + sum);
  15. }
RAW Paste Data