First post.
The code below works, sorting my answers alphabetically, but I am having a hard time adding a conditional to my program.
I believe I need to include an if/else statement so that every other answer is in caps.
ie: names = ["Bob", "Joe", "Bill", "Fred"] desired output =
BILL
bob
FRED
joe
The code:
names = []
4.times do puts "Please enter your amigo's names:" names << gets.chomp end
SortNames = names.sort
SortNames.each do |name| puts "There once was a person named " + name + "."
end
Thank you very much for your help!!
Aucun commentaire:
Enregistrer un commentaire