I'd like this method to circle through each item in the array of names katz_deli and use puts to display the name and its index. However, the output is just the first name in the array with its index.
My code:
def line (katz_deli)
if katz_deli.count > 1
katz_deli.each_with_index {|name, index| puts "The line is currently: #{index +1}. #{name}" }
else
puts "The line is currently empty."
end
end
I want my output to be "The line is currently: 1. Logan 2. Avi 3. Spencer"
But I'm getting "The line is currently: 1. Logan." Thanks!
line([ "Logan", "Avi", "Spencer" ])I get three lines of output:The line is currently: 1. Logan,The line is currently: 2. Avi, andThe line is currently: 3. Spencer.The line is currently: 1. Logan 2. Avi 3. SpencerI'm doing this for a course and I think that's what the instructors are looking for. Thanks!