Js objects creation

Continuing the discussion from Data Structures (Arrays and Objects) - Reading Assignment:

1 Like

Hey @Su.kal.Crypto, hope you are well.

Now about your object, You have a mistype ]; at the end which is not necessary, also you are not declaring correctly the variable.
here is the same object but correcting those errors.

var journal1 =
{
  Monday: {
    events : ["work", "touched tree", "pizza", "running","television"], 
    squirrel : false
    },
  Tuesday : {
    events : ["work", "ice cream", "cauliflower", "lasagna","touched tree", "brushed teeth"],
    squirrel : false
    },
  Wednesday : {
    events : ["weekend", "cycling", "break", "peanuts","beer"],
    squirrel : true
    }
}

Then I define the variable in the console just to check there is no error in the syntax and is working properly, you can call the entire object or a property of it.


If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Hey Thanks a Ton Carlos. I am extremely grateful.

But you know my question actually was "How to take and empty [] and using a function add the expressions and objects to it.

Later with sheer perseverance and some trial and error i found a simple way , as below:

Just for my knowledge again, let me know if i have done this correctly, or is there a better way to do it ?
This wasn’t covered in Ivan’s course, just out of curiosity i tried to push objects in the blank array using the above function.

Thanks again