Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ Using the annoyingSong function below do the following:
"{number} bottles of soda on the wall, {number} bottles of soda, take one down pass it around {number left over} bottles of soda on the wall"
*/

//not what I understood the task to be, but it passes npm and my idea did not...
function annoyingSong(num){
for (let i=num; i>0; i--){
return(`${i} bottles of soda on the wall, ${i} bottles of soda, take one down pass it around ${(i-1)} bottles of soda on the wall`);
Expand Down Expand Up @@ -332,8 +333,37 @@ HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
vowelCounter("CHEESE");

function vowelCounter(str) {
const lower = str.toLowerCase();//case sensitive, so make lower

const chars = lower.split(''); //splits word into an array of characters

let count = 0; //for counting vowels

for (let i=0; i< str.length; i++){ //step through the array and check if is vowel
//console.log(chars[i]);
if (chars[i] === "a"){
count++; //if a vowel, increment the count
}
else if (chars[i] === "e"){
count ++;
}
else if (chars[i] === "i"){
count ++;
}
else if (chars[i] === "o"){
count ++;
}
else if (chars[i] === "u"){
count ++;
}
else if (chars[i] === "y"){
count ++;
}
}
return count;
}


Expand Down