Get Programming with JavaScript - Listing 3.07
Listing 3.07 - Objects with multiple properties
JS Bin
var book1;
var book2;
book1 = {
title : "The Hobbit",
author : "J. R. R. Tolkien"
};
book2 = {
title : "Northern Lights",
author : "Philip Pullman"
};
Further Adventures
Listing 3.07 - Objects with multiple properties - Task 1
- Add a third property to each book.
var book1;
var book2;
book1 = {
title : "The Hobbit",
author : "J. R. R. Tolkien",
published : 1937 // add a third property
};
book2 = {
title : "Northern Lights",
author : "Philip Pullman", // don't forget the comma
published : 1995
};
Listing 3.07 - Objects with multiple properties - Task 2
- Add spaces so that the colons line up.
var book1;
var book2;
book1 = {
title : "The Hobbit",
author : "J. R. R. Tolkien",
published : 1937
};
book2 = {
title : "Northern Lights",
author : "Philip Pullman"
published : 1995
};
Listing 3.07 - Objects with multiple properties - Task 3
- Log both objects to the console.
var book1;
var book2;
book1 = {
title : "The Hobbit",
author : "J. R. R. Tolkien",
published : 1937
};
book2 = {
title : "Northern Lights",
author : "Philip Pullman"
published : 1995
};
console.log(book1); // log to the console
console.log(book2); //