title: Remove comma from last element in loop
body: <p>In a rails app view I'm outputting data from an Array separated by commas. How to remove the comma from the last element? I could do:</p>
  
  <pre><code>html = ""
  answer.first.selected_answers.each do |sa|
    if answer.first.selected_answers[-1] == sa
      html &lt;&lt; content_tag(:span, "#{sa.possible_answer.text}", class: 'answer')
    else
      html &lt;&lt; content_tag(:span, "#{sa.possible_answer.text}, ", class: 'answer')
    end
  end
  html.html_safe
  </code></pre>
  
  <p>Is there a more elegant way? Maybe using JQuery? Or CSS <code>last-child</code>?</p>