Skip to content

Instantly share code, notes, and snippets.

@NevadaKiran
Created March 19, 2015 21:03
Show Gist options
  • Select an option

  • Save NevadaKiran/a269bb87f8fc779eeac8 to your computer and use it in GitHub Desktop.

Select an option

Save NevadaKiran/a269bb87f8fc779eeac8 to your computer and use it in GitHub Desktop.
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 each letter and print whether it is a vowel or a consonant.
letters.each_with_index do |letter, index|
#check if vowels include 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