ProdanTenev

Vowels Sum

Feb 25th, 2022
1,410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.52 KB | None | 0 0
  1. function vowelsSum(input) {
  2.     let text = input[0];
  3.     let totalSum = 0;
  4.     for (let index = 0; index < text.length; index++) {
  5.         let letter = text[index];
  6.         if (letter === "a") {
  7.             totalSum += 1;
  8.         } else if (letter === "e"){
  9.             totalSum += 2;
  10.         } else if (letter === "i"){
  11.             totalSum += 3;
  12.         } else if (letter === "o"){
  13.             totalSum += 4;
  14.         } else if (letter === "u"){
  15.             totalSum += 5;
  16.         }
  17.     }
  18.     console.log(totalSum);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment