addToBasket = (id, qty) -> if $.cookie('basket')? # Basket exists basket = $.parseJSON($.cookie('basket')) basket.push( { 'id': id, 'qty': qty } ) $.cookie('basket', JSON.stringify(basket)) else # Basket doesn't exist alert 'Creating basket' basket = JSON.parse([{'id': id, 'qty': qty}]) $.cookie('basket', JSON.stringify(basket))
I pull my hair out; I cannot run the function (compiled equivalent), always getting an illegal token error. I checked for rogue, invisible characters and there is nothing but CR / LFs there.
coffeescript
user1381745
source share