Get Programming with JavaScript - Listing 4.06

Listing 4.06 - Calling the sayHello function three times

var sayHello; sayHello = function () { console.log("Hello World!"); }; sayHello(); sayHello(); sayHello();

Further Adventures

Listing 4.06 - Calling the sayHello function three times - Task 1

var sayHello; sayHello = function () { console.log("I'm going on an adventure!"); // Change the message }; sayHello(); sayHello(); sayHello();

Listing 4.06 - Calling the sayHello function three times - Task 2

var sayHello; sayHello = function () { console.log("Hello\nWorld!"); // Use a line-break }; sayHello(); sayHello(); sayHello();

Listing 4.06 - Calling the sayHello function three times - Task 3

var sayHello; sayHello = function () { console.log("H\ne\nl\nl\no\nW\no\nr\nl\nd\n!"); // Use line-breaks }; sayHello(); sayHello(); sayHello();

You could also use a separate call to console.log for each letter.