Loops
Goals
Step 1
IRB3.times { puts 'Hip, hip, hooray!'}
Step 2
IRBbeatles = [ "John", "Paul", "George", "Ringo"] beatles.each { |beatle| puts "Hi, my name is #{beatle}"}IRBducks = ['Huey', 'Dewey', 'Louie'] ducks.each { |duck| puts "#{duck} quacks!" } ducks.each { |zombie| puts "#{zombie} quacks!" }
Step 3
IRB('a'..'z').each { |letter| puts letter }IRB('a'...'z').each { |letter| puts letter }
Step 4
IRBtotal = 99 colors = ['red', 'blue', 'green'] colors.each do |color| puts "#{total} colors of paint on the wall..." puts "Take #{color} down, pass it around..." total = total - 1 puts "#{total} colors of paint on the wall!" end
Challenge(s)
Oh, hello, Sally Samsonite! Oh, hello, Johnny Jameson! Oh, hello, Beth Benitsky! Oh, hello, Corinne Camelia!The sum of all of the numbers is 30.
Explanation
Next Step:
Go on to Summary: Basics
Back to Hashes