Please help to complete Ruby Array Code


#Please fill the empty array “statements” ??? with values, to print it

statements = [“kitten” , "puppies , “piglets”]
[“kittens”, “puppies”, “piglets”].each do |animal|
statement = "I love " + animal

add the statement to the statements array here.

puts statements


Neither ‘kittens’, ‘puppies’, nor ‘piglets’ are statements so my first criticism to the course author would be to match object names as closely as possible to what they reference.

In this case it looks like animals, or pets, perhaps.

animals = [ 'kittens', 'puppies', 'piglets' ]

Now given the above iterable, iterate…

animals.each do |animal|
    puts "I love " + animal + "."


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.