/* Basic Function */
function reusableFunction() {
console.log("Hello World");
}
reusableFunction();
/* Passing Values to Functions with Arguments */
function functionWithArgs(arg1, arg2 ) {
console.log(arg1 + arg2);
}
functionWithArgs(1, 2); //returns 3
/* Global vs. Local Scope in Functions
It is possible to have both local and global variables with the same name.
When you do this, the local variable takes precedence over the global variable. */
var outerWear = "T-Shirt";
function myOutfit() {
var outerWear = "sweater"
return outerWear;
}
myOutfit(); //returns "sweater"