I have a JavaScript object customer
that looks like this...
Object {
name: "John Doe",
age: "26"
}
I want to create a cars
section and add some specifics so it looks like this...
Object {
name: "John Doe",
age: "26"
cars: {
car1 {
color: red,
type: ford
},
car2 {
color: blue,
type: GMC
},
car3 {
color: white,
type: toyota
}
}
}
I have tried to do this like this...
customer['cars']['car1'] = { color:'white', type:'toyota' }
But this gives me the error...
customer.cars is undefined
Where am I going wrong?