Skip to content

Instantly share code, notes, and snippets.

@mahasak
Last active December 12, 2016 16:39
Show Gist options
  • Select an option

  • Save mahasak/c708f267a6ec0edbeaae990ab39b721b to your computer and use it in GitHub Desktop.

Select an option

Save mahasak/c708f267a6ec0edbeaae990ab39b721b to your computer and use it in GitHub Desktop.
// Global Scope
var bear = "Brother Bear";
function greetTheBear() {
return alert(bear);
}
// Function Scope (Local Scope)
function greetTheBigBear() {
var greet = "BearHunter";
return alert(greet);
}
alert(greet); //Error here !!!!
// Function Scope (Nested)
function hailTheHusky(huskyName) {
function caplitalize() {
return huskyName.toUpperCase();
}
var capitalized = caplitalize();
return capitalized;
}
alert(hailTheHusky("HuskyBear"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment