this is almost certainly a potential bug in IE9+  -- vars should be declared as such for correct scoping.   use var quantity instead.