Skip to content

Instantly share code, notes, and snippets.

@wkdalsgh192
Created September 4, 2021 12:30
Show Gist options
  • Save wkdalsgh192/d3a274c7632be44d33c4526768bf07ae to your computer and use it in GitHub Desktop.
Save wkdalsgh192/d3a274c7632be44d33c4526768bf07ae to your computer and use it in GitHub Desktop.
// 2. Pass a function as a parameter
function sayHello() {
return "Hello, ";
}
function greeting(helloMessage, name) {
console.log(helloMessage() + name);
}
greeting(sayHello, "JavaScript!");
// 3. Return a function
function sayHello() {
return function() {
console.log("Hello!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment