Please help to complete Ruby Array Code


#1

#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.

???
end
puts statements


#2

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 + "."
end

#3

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