Created
August 9, 2023 16:20
-
-
Save suhailgupta03/1e0ef289e246e1f961f789127df4e81b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);