Get Programming with JavaScript - Listing 3.02
Listing 3.02 - Using prefixes to tell book variables apart
JS Bin
var book1Title = "The Hobbit";
var book1Author = "J.R.R.Tolkien";
var book2Title = "Northern Lights";
var book2Author = "Philip Pullman";
var book3Title = "The Adventures of Tom Sawyer";
var book3Author = "Mark Twain";
console.log("There are three books so far...");
console.log(book1Title + " by " + book1Author);
console.log(book2Title + " by " + book2Author);
console.log(book3Title + " by " + book3Author);
Further Adventures
Listing 3.02 - Using prefixes to tell book variables apart - Task 1
var book1Title = "The Hobbit";
var book1Author = "J.R.R.Tolkien";
var book2Title = "Northern Lights";
var book2Author = "Philip Pullman";
var book3Title = "The Adventures of Tom Sawyer";
var book3Author = "Mark Twain";
var book4Title = "Twenty Thousand Leagues Under The Sea"; // fourth book
var book4Author = "Jules Verne"; //
console.log("There are three books so far...");
console.log(book1Title + " by " + book1Author);
console.log(book2Title + " by " + book2Author);
console.log(book3Title + " by " + book3Author);
Listing 3.02 - Using prefixes to tell book variables apart - Task 2
var book1Title = "The Hobbit";
var book1Author = "J.R.R.Tolkien";
var book2Title = "Northern Lights";
var book2Author = "Philip Pullman";
var book3Title = "The Adventures of Tom Sawyer";
var book3Author = "Mark Twain";
var book4Title = "Twenty Thousand Leagues Under The Sea";
var book4Author = "Jules Verne";
console.log("There are four books so far..."); // update messages
console.log(book1Title + " by " + book1Author);
console.log(book2Title + " by " + book2Author);
console.log(book3Title + " by " + book3Author);
console.log(book4Title + " by " + book4Author); // update messages