Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Write a function that returns the count of the total number of vowels in a string.
- Example: 'Hello World!' -> 3 */
- function vowelCount(str) {
- let num = 0;
- let count = 0;
- for(num=0;num<str.length;num++){
- if(str.charAt(num).toUpperCase() === 'A'){count ++}
- else if(str.charAt(num).toUpperCase() === 'E')
- {count ++}
- else if(str.charAt(num).toUpperCase() === 'I')
- {count ++}
- else if(str.charAt(num).toUpperCase() === 'O')
- {count ++}
- else if(str.charAt(num).toUpperCase() === 'U')
- {count ++}
- else {}
- }
- return count;
- }
- console.log(vowelCount('Good Job!'));
Add Comment
Please, Sign In to add comment