I have been working on this for hours and can't figure it out. I have a checklist object sorted by category, and each category is an array of task objects. I am trying to allow the user to add a task to a given category array, but cannot figure it out. Each time I try to log the array, it just prints out the observer and says that '.push' is not a function.
I think the issue is dealing with using a variable to get the array because when I hard code in 'masterChecklist["General Cleaning"]', it will work. Please help!
** The example below is simplified
var masterChecklist = {
"General Cleaning":
[
{cleaned: false, notes: "", name: 'Empty and sanitize trash bins'},
{cleaned: false, notes: "", name: 'Clean mirrors and windows'},
],
"Home Exterior":
[
{cleaned: false, notes: "", name: 'Wipe and clean all furniture'},
{cleaned: false, notes: "", name: 'Empty the trash bins'},
],
}
SaveTaskDetails("Dust", "Make sure to get the shelves", "General Cleaning")
function SaveTaskDetails(name, notes, category) {
var newTask = {
name: name,
notes: notes,
cleaned: false
}
var category = masterChecklist[category].push(newTask)
}
console.log(masterChecklist);
