title: Closures: Scope Chain Variables - Not sure how variables link up
body: <p>Really new to Javascript. This code is taken from MDN.</p>
  <pre><code>// global scope
  var e = 10;
  function sum(a){
    return function sum2(b){
      return function sum3(c){
        // outer functions scope
        return function sum4(d){
          // local scope
          return a + b + c + d + e;
        }
      }
    }
  }
  
  var s = sum(1);
  var s1 = s(2);
  var s2 = s1(3);
  var s3 = s2(4);
  console.log(s3) //log 20
  </code></pre>
  <p>When I try to input different variable names (EX below) they don't seem to work and I don't understand how everything links up together to spit out the answer 20.</p>
  <pre><code>// global scope
  var e = 10;
  function sum(a){
    return function sum2(b){
      return function sum3(c){
        // outer functions scope
        return function sum4(d){
          // local scope
          return a + b + c + d + e;
        }
      }
    }
  }
  
  var w = sum(1);
  var x = s(2);
  var y = s1(3);
  var z = s2(4);
  console.log(s3) //log 20
  </code></pre>
  <p>When I change it to this it also does not work. The console tells me that sa is not defined</p>
  <pre><code>// global scope
  var e = 10;
  function sm(a){
    return function sa(b){
      return function sb(c){
        // outer functions scope
        return function sc(d){
          // local scope
          return a + b + c + d + e;
        }
      }
    }
  }
  
  var s = sm(1);
  var s1 = sa(2);
  var s2 = sb(3);
  var s3 = sc(4);
  console.log(sc) //log 20
  </code></pre>
  <p>I can keep throwing out more examples that don't work. Someone, please help me understand how the first example works.</p>