Guest User

Untitled

a guest
Dec 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. /* Write a function that returns the count of the total number of vowels in a string.
  2. Example: 'Hello World!' -> 3 */
  3.  
  4. function vowelCount(str) {
  5. let num = 0;
  6. let count = 0;
  7. for(num=0;num<str.length;num++){
  8. if(str.charAt(num).toUpperCase() === 'A'){count ++}
  9. else if(str.charAt(num).toUpperCase() === 'E')
  10. {count ++}
  11. else if(str.charAt(num).toUpperCase() === 'I')
  12. {count ++}
  13. else if(str.charAt(num).toUpperCase() === 'O')
  14. {count ++}
  15. else if(str.charAt(num).toUpperCase() === 'U')
  16. {count ++}
  17. else {}
  18. }
  19. return count;
  20.  
  21. }
  22. console.log(vowelCount('Good Job!'));
Add Comment
Please, Sign In to add comment