Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 16, 2023 14:57
Show Gist options
  • Save suhailgupta03/896b1b92a6ad3dfa1530dc7349276ea5 to your computer and use it in GitHub Desktop.
Save suhailgupta03/896b1b92a6ad3dfa1530dc7349276ea5 to your computer and use it in GitHub Desktop.
function sum(a, b) {
return a + b;
}
function subtract(a, b) {
return a - b;
}
function sin(theta) {
return Math.sin(theta);
}
function cos(theta) {
return Math.cos(theta);
}
function composeExample(arg1, arg2) {
var x = 1;
var y = 2;
var result1 = arg1(x, y); // 3
var result2 = arg2(x,y); // -1
return result1 * result2;
}
console.log(composeExample(sum, subtract));
console.log(composeExample(sin, cos));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment