sebdev
4/29/2019 - 8:07 PM

Saved from https://classroom.udacity.com/nanodegrees/nd001/parts/4942f4d7-a48d-4794-9eb0-404b3ed3cfe1/modules/7e56389b-50d8-4e3a-84a0-eb3fd4

const myName = 'Andrew';
// Global variable

function introduceMyself() {

  const you = 'student';
  // Variable declared where introduce() is defined
  // (i.e., within introduce()'s parent function, introduceMyself())

  function introduce() {
    console.log(`Hello, ${you}, I'm ${myName}!`);
  }

  return introduce();
}

// the introduceMyself() function contains a nested introduce() function. While introduce() does not take in any arguments, nor are there any local variables declared within it -- variables in both the aforementioned settings are indeed in introduce()'s scope.
// introduce() does use the global variable myName, however, as well as the you variable contained in its parent function, introduceMyself() (where introduce() was defined).