I am building a web application in which a user can enter their own product names into a database, but if they add in a ` ' or " it breaks my application, I am pretty sure it is breaking right here:
$cart.innerHTML = items.map((item) => `
<a href="#" onClick="cartLS.remove(${item.id}); gaRemoveFromCart('${item.name}');" title="Remove This Item" class="btn-remove"><i class="fas fa-times"></i></a>
</div>
</li>
`).join("");
How can I properly escape if there is any ' in the item name?