Skip to content Skip to sidebar Skip to footer

Vue App, Javascript, Conditionally Adding An Object To An Array

I have a restaurant menu which is an array of objects each of which has the following properties:- name id - the id is autogenerated quantity options - which itself is an array th

Solution 1:

This seems more of a data structure issue rather than a syntax or coding issue. In your case I'd add a duplicate pizza, one for each size. That way you can still increment the amount. IE:

  • Pineapple Pizza (small) 1x

  • Pineapple Pizza (large) 1x

    You'd have to restructure your data if you'd want to

  • Pineapple Pizza 2x (small & large)

Your question doesn't really show what solution you want.

Post a Comment for "Vue App, Javascript, Conditionally Adding An Object To An Array"