Get Programming with JavaScript - Listing 6.02

Listing 6.02 - Using an argument to determine the return value

var getHelloTo; var fullMessage; getHelloTo = function (name) { return "Hello to " + name; }; fullMessage = getHelloTo("Kandra"); console.log(fullMessage);

Further Adventures

Listing 6.02 - Using an argument to determine the return value - Task 1

var getHelloTo; var fullMessage; getHelloTo = function (name1, name2) { // accept two parameters return "Hello to " + name; }; fullMessage = getHelloTo("Kandra"); console.log(fullMessage);

Listing 6.02 - Using an argument to determine the return value - Task 2

var getHelloTo; var fullMessage; getHelloTo = function (name1, name2) { return "Hello to " + name1 + " and " + name2; // update the return value }; fullMessage = getHelloTo("Kandra", "Dax"); // use two arguments console.log(fullMessage);