Created
August 26, 2024 22:36
-
-
Save Vampeyer/0fc0a0dad5eb86115d8503b2b2e132a2 to your computer and use it in GitHub Desktop.
JavaScript Mastery - Kata 3 Vowels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Vowels . | |
// Kata 3 - Vowels | |
// Assignment | |
// 30m - 1h | |
// Status | |
// Incomplete | |
// In this exercise, you will be counting the number of vowels that appear in a given string. For this exercise, consider the following to be vowels: a, e, i, o, and u. | |
// Input | |
// const numberOfVowels = function(data) { | |
// // Put your solution here | |
// }; | |
// console.log(numberOfVowels("orange")); | |
// console.log(numberOfVowels("lighthouse labs")); | |
// console.log(numberOfVowels("aeiou")); | |
// Expected Output | |
// 3 | |
// 5 | |
// 5 | |
let string = 'one big ole cup of applesauce and one big ole cup of fried chicken. '; | |
let vowels = ["a" , "e" , "i" , "o" , "u"] | |
let vowelsTotal = 0 | |
function numberOfVowels(string, numberOfVowels){ | |
for (let i in string){ | |
// console.log(string[i]) | |
for( let j in vowels){ | |
if (vowels[j] == string[i]){ | |
// console.log(string[i]) // All the vowels in the string. | |
vowelsTotal += 1 | |
} | |
} | |
} | |
return vowelsTotal | |
} | |
// Logs the total number of vowels | |
console.log( numberOfVowels(string , numberOfVowels)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment