When I try to pass a string as an argument in the following function, I get the Uncaught SyntaxError: missing ) after argument list error. It works fine when passing integers though. I am confused because I read a string must be passed as the argument, and not an integer.
HTML:
r.title = "The large item"
counter = <integer>
<% @items.each do |r| %>
<p>Title: <%= r.title %></p>
<p>Price: <%= r.price %></p>
<p>Description: <%= r.description %></p>
<p style="color:blue;" class="room_<%= counter %>" onclick='addItemToCart(<%= r.title %>, <%= counter %>)'>Select Item</p>
<br>
<br>
<% end %>
When I pass r.id in place of r.title, the code works.
JavaScript:
<script text/javascript>
function addItemToCart(title, item_number){
$("#" + item_number).append("<br>"+title);
}
</script>


