Created
March 18, 2015 14:03
-
-
Save phlipper/b228516f79e92fa8403d to your computer and use it in GitHub Desktop.
TECH601-00 Day 5 Example - Lists of Letters and 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
letters = "a".."g" | |
vowels = ["a", "e", "i", "o", "u"] | |
# Loop through each letter and print whether it is a vowel or consonant | |
# letters.each_with_index do |letter, index| | |
# if letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u" | |
# puts "vowel at index #{index}" | |
# else | |
# puts "consonant at index #{index}" | |
# end | |
# end | |
# Loop through each letter and print whether it is a vowel or consonant | |
letters.each_with_index do |letter, index| | |
# check if the list of vowels includes the current letter | |
if vowels.include?(letter) | |
puts "vowel at index #{index}" | |
else | |
puts "consonant at index #{index}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vowel at index 0
consonant at index 1
consonant at index 2
consonant at index 3
vowel at index 4
consonant at index 5
consonant at index 6