I'm rewriting a project with hardcoded values to be flexible and dynamic. However, I keep running into trouble.
I wrote most of my JS code now, but I found a couple of bugs that I can't fix, so I decided to start from scratch. I was now thinking to put my data into an object which keeps track of totals. The project basically lets people order tickets, hotels, etc. per event.
However, this used to be hardcoded, like I said. Now it has to be flexible and I'm not sure if it's possible to dynamically create an object? Here's my problem:
The object I used to use was the following:
var total = { amount: 0,
tickets: 0,
passes: 0,
fri: 0,
sat: 0,
sun: 0,
freecarpass: 0,
freepass_fri: 0,
freepass_sat: 0,
freepass_sun: 0,
passes_fri: 0,
passes_sat: 0,
passes_sun: 0,
passes_totalPurchase: 0
};
As you can see, the days are hardcoded. However, with the new system, every event will have different days, so I need to be able to build my object based on that, if that makes sense.
For example, if the event runs from wednesday till saturday, the days in the object would be:
wed: 0, thu: 0, fri: 0, sat: 0
etc.
I'm not sure how to achieve this, if this is even possible? I can provide more code of the project if needed. Thanks in advance.