Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 9, 2023 16:20
Show Gist options
  • Save suhailgupta03/1e0ef289e246e1f961f789127df4e81b to your computer and use it in GitHub Desktop.
Save suhailgupta03/1e0ef289e246e1f961f789127df4e81b to your computer and use it in GitHub Desktop.
function greet(name) {
return `Hello, ${name}!`;
}
function shout(textFunction, name) {
const text = textFunction(name);
// toUpperCase is a built-in function of the
// String object which returns the value of
// the string converted to uppercase (capital letters)
const shoutText = text.toUpperCase();
return shoutText;
} // here shout is a higher order function
// because it takes a function as an argument
var a = shout(greet, 'John');
console.log(a);
@suhailgupta03
Copy link
Author

function greet(name) {
return Hello, ${name}!;
}

function greetV2(name) {
return Namaste, ${name}!;
}

function shout(textFunction, name) {
const text = textFunction(name);
// textFunction <<->> greet
// toUpperCase is a built-in function of the
// String object which returns the value of
return text;
} // here shout is a higher order function
// because it takes a function as an argument

var a = shout(greetV2, 'Suhail');
console.log(a);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment