how to add to javascript objects? code example
Example 1: add property to object javascript
let yourObject = {};
//Examples:
//Example 1
let yourKeyVariable = "yourKey";
yourObject[yourKeyVariable] = "yourValue";
//Example 2
yourObject["yourKey"] = "yourValue";
//Example 3
yourObject.yourKey = "yourValue";
Example 2: js create object with properties
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}