title: Functions With Global Inputs Return NaN
body: <p><strong>Edit:</strong></p>
  
  <p>I wanted to be more specific about why I'm doing it this way.  The code below is something I've been attempting to get working.</p>
  
  <pre><code>function newClass(self) {
      this.invest;
      this.interest;
      function method1() {
          return this.invest + this.interest;
      }
  }
  var newC = new newClass();
  newC.invest = prompt("Enter investment");
  newC.interest = prompt("Enter interest");
  alert(newC.method1());
  </code></pre>
  
  <p><strong>End Of Edit:</strong></p>
  
  <p>I'm fairly new to the javascript language and can not figure out why my functions are always returning NaN.  I have attempted many different fixes but nothing I have tried works.  Below is an example.</p>
  
  <pre><code>function investment() {
      var iniInvest;
      var interest;
      return iniInvest + interest;
  }
  
  investment.iniInvest = 10;
  investment.interest = 20;  
  console.log(investment())
  </code></pre>
  
  <p>This returns a NaN. I have attempted creating classes and methods and attempted to parse the variables but they still all return NaN.</p>
  
  <p>Unless the variables values are assigned to the var in the function </p>
  
  <pre><code>var iniInvest = 10;
  </code></pre>
  
  <p>or args are given </p>
  
  <pre><code>function investment(args1, args2) {
      return args1 + args2;
  }
  console.log(investment(10, 20));
  </code></pre>
  
  <p>it will return NaN.</p>
  
  <p>I appreciate the help.</p>