Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log(buildName("Vadim"));
- var sayMyName = buildName("Vadim");
- sayMyName();
- ƒ () {
- var welcome = greeting + " Welcome!";
- console.log(welcome);
- }
- function buildName(name) {
- var greetings = "Hello," + name + "!";
- var sayName = function() {
- var welcome = greetings + "Welcome!";
- console.log(welcome);
- };
- return sayName;
- };
- var sayMyName = buildName("Vadim");
- sayMyName();
- function createGreeter(greeting) {
- return function greeter(name) {
- console.log(`${greeting}, ${name}!`);
- }
- }
- const morningGreeter = createGreeter("Good morning"); // morningGreeter here is a function, which, when called, will log "Good morning, NAME!".
- morningGreeter("John"); // this will log "Good morning, John!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement