Get Programming with JavaScript - Listing 19.03

Listing 19.03 - Chaining calls to replace

var data = { author : "Oskar", social : "@appOskar51" }; var before = "Follow {{author}} {{social}}"; var after = before .replace("{{author}}", data.author) .replace("{{social}}", data.social); console.log(before); console.log(after);

Further Adventures

Listing 19.03 - Chaining calls to replace - Tasks 2 to 4

var data = { firstName : "Oskar", lastName : "Smith", social : "@appOskar51" }; var before = "Follow {{firstName}} {{lastName}} {{social}}"; var after = before .replace("{{firstName}}", data.firstName) .replace("{{lastName}}", data.lastName) .replace("{{social}}", data.social); console.log(before); console.log(after);