Skip to content

Instantly share code, notes, and snippets.

@Maccauhuru
Last active January 16, 2019 00:39
Show Gist options
  • Save Maccauhuru/0a2592f743bd26ec5ba6fe7de402dd62 to your computer and use it in GitHub Desktop.
Save Maccauhuru/0a2592f743bd26ec5ba6fe7de402dd62 to your computer and use it in GitHub Desktop.
Example of Function Expression 2
//To invoke the function,i will try call its name (addNumbers) and give it 2 parameters
addNumbers(5,2); // Uncaught ReferenceError: addNumbers is not defined
addNumbers(100,1); // Uncaught ReferenceError: addNumbers is not defined
//A simple function expression named addNumbers that accepts 2 input parameters
const addNumbers = function addTwoNumbers(num1,num2){
let sum = num1 + num2;
return sum;
}
//To invoke the function,i will try again to call its name (addNumbers) and give it 2 parameters
addNumbers(5,2); // will output : 7
addNumbers(100,1); // will output : 101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment