Skip to content

Instantly share code, notes, and snippets.

@phlipper
Created March 18, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phlipper/b228516f79e92fa8403d to your computer and use it in GitHub Desktop.
Save phlipper/b228516f79e92fa8403d to your computer and use it in GitHub Desktop.
TECH601-00 Day 5 Example - Lists of Letters and Vowels
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
@NevadaKiran
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment