Read the code in each section, then write exactly what the code prints out.
Each problem stands alone. Variables from previous problems do not exist.
Example:
x = 5
y = 6
print(x+y)
# => 11
cars = ["old", "new", "used"]
cars.each do |car|
puts car
end
fruits = ["banana", "apple", "kiwi"]
fruits.each do |fruit|
puts "I love " + fruit + "!"
end
values = [8, 5, 3, 10, 14, 2]
values.each do |value|
puts value
end
total = 0
values = [4, 6, 2, 8, 11]
values.each do |value|
total = total + value
end
puts total
values = [8, 5, 3, 10, 14, 2]
values.each do |value|
if value == 10
puts "Special case!"
else
puts "Regular values like #{value}"
end
end
When you are complete with all of these problems, you can check your answers against the answer key.