I have this array in the global scope:
const orders = [];
I want to push an object to this array.
const addItem = ($id, $name, $price) => {
const $item = ({
id: $id,
name: $name,
price: $price,
amount: 1
});
orders.Push = $item;
return orders;
};
The thing is that I want to push an object into the array after every clickevent. For now it only adds 1 object to the array for the first clickevent, but after I click another time, it won't push anymore.