How can I iterate through an array of numbers, and add a string to the output in each iteration? I'm using "puts" to display the number.
The array
nums = Array[1, 2, 3, 4, 5]
Iterating the array
for i in nums
puts i + " Carrots"
end
I'm getting this response
test.rb:40:in `+': String can't be coerced into Integer (TypeError)String can't be coerced into Integer (TypeError)String can't be coerced into Integer (TypeError)
i.to_s