Count Vowels

Write a method that takes a string and returns the number of vowels in the string. You may assume that all the letters are lower cased.  You can treat “y” as a consonant.

Screen Shot 2016-08-11 at 2.57.21 PM.png

Note: I overcomplicated this problem in my mind.  Remember to use += 1 to count something.

Second time solving this:


I forgot to initialize count to 0  (I apparently forgot the first time as well)  and I also started off splitting the string into letters, which was unnecessary.

Third time, using a hash map (with the help of Josh)!

Screen Shot 2016-11-01 at 9.50.42 PM.png

By using hash, it would be more efficient to add more vowels later.

Count Vowels

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s