I need help outputting the code below

votes = ["Bob's Dirty Burger Shack", "St. Mark's Bistro", "Bob's Dirty Burger Shack"]

votes.reduce(Hash.new(0)) do |result, vote|
  result[vote] += 1
  result
end

code in use

I managed to figure it out:

votes = ["Bob's Dirty Burger Shack", "St. Mark's Bistro", "Bob's Dirty Burger Shack"]

def votesWon(votes)
votes.reduce(Hash.new(0)) do |result, vote|
  result[vote] += 1
  result
end

end

print votesWon(votes)

Good work @ayanda!

I know nothing about Ruby, so can’t really help you here. Is there a dedicated Ruby forum you could ask these questions on?

I’ve no idea tbh cause I sorta just started it and it hasn’t gotten to the part about forums to engage in.

Which back end languages did you dive into during your learning stages?

I am not great at back-end languages. When I need to hack something together on the back-end, I mainly tend to use Node.js (as it’s JS, and I know JS well) or Python (very popular, good support, nice language to write)

1 Like

Apparently Python an ruby are quite similar! I managed to find a ruby forum to similar to this forum. I just hope it is as responsive :slight_smile:

Yes, it does look pretty similar — use of the def keyword, indentation, etc.