Javascript Function Creation Question 6

Introduction

What is the output of the following code?

function greetingMaker(greeting) {
   function addName(name) {
      return greeting + " " + name;
   }//from  w w  w .j  a  v a  2s . com
   return addName;
}

// Now, create new partial functions
let daytimeGreeting = greetingMaker("Good Day to you");
let nightGreeting = greetingMaker("Good Evening");

let name = 'Reader';

console.log(daytimeGreeting(name));

console.log(nightGreeting(name));


Good Day to you Reader
Good Evening Reader



PreviousNext

Related