My goal is to create an array of JavaScript objects and would like the output to be in a format like below:
journal = [
{
events: ["work", "ice cream", "cauliflower",
"lasagna", "touched tree", "brushed teeth"
],
squirrel: false
},
{
events: ["weekend", "cycling", "break", "peanuts",
"soda"
],
squirrel: true
}
];
The goal is to build from the following function with both given parameters (events and squirrel)
let journal = [];
function addEntry(events, squirrel) {
...........
...........
}
I wrote the code below and the output is giving me an error: "false is not a function". How can I fix that error and get the output expected? Thanks
let journal = [];
function addEntry(events, squirrel) {
journal.push(
({
events: ["work", "ice cream", "cauliflower", "lasagna", "touched tree", "brushed teeth"]
}, false)
({
events: ["weekend", "cycling", "break", "peanuts", "soda"]
}, true)
)
}
addEntry(console.log(journal));