I am trying to create an array with 7 objects (each per day). Idea is to create store hours for 7 days.
Final Dictionary will be like this:
const storeHours = {
monday: { startTime: mondayTime1, endTime: mondayTime1 },
tuesday: { startTime: new Date(), endTime: new Date() },
wednesday: { startTime: new Date(), endTime: new Date() },
// other days ...
};
I have 7 checkboxes, one for each day.
When I click checkbox, it stores checked item in an array.
checkedValues = ["Friday", "Saturday"]
I can use this checkedValues items to know which entry to make in newDict.
like this:
newDict = {
monday: { startTime: mondayTime1, endTime: mondayTime1 },
}
When I click second checkbox, newDict should have new entry for that day and so on.
When I un-check the checkbox I have to also remove the entry from this dictionary, so both, checkbox and dictionary, remain in sync.
how do I remove an entry from dictionary when an item is un-checked?
Whole idea is to basically store store hours in database with dictionary with 7 objects..