arrays - How to have the user input alternate between uppercase and lowercase in Ruby? -


i have ruby ask user 5 times enter name, , want answers spat out each line alternate uppercase , lowercase. below have done , prints out each name twice, 1 uppercase 1 lowercase. want each line alternate between uppercase , lowercase. hope i'm making sense here...

football_team = []  5.times      puts "please enter uk football team:"     football_team << gets.chomp end  football_team.each |football_team|     puts team.upcase     puts team.downcase end 

football_team = []  5.times    puts "please enter uk football team:"   football_team << gets.chomp end  football_team.each_with_index |team, index|   if index.even?     puts team.upcase   else     puts team.downcase   end end 

note should use identifiers starting capitals constants. while football_team might constant, not idea. note loop variable wrong.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -