title: How to insert dictionary values as arguments in JavaScript?
body: <p>I'm outputting an array that will return the amount owed on a loan based on the <code>loanAmount</code>, <code>interest</code>, and <code>loanTermYears</code> for the dictionary <code>instance1</code>. The dictionary is printed successfully. However, <code>calculatedLoanAmount</code> returns NaN. The function calculateAmount is not properly reading the key-value pairs correctly. How do I properly insert these key-value pairs as arguments so that the function can return the total amount owed?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var info = []
  var instance1 = new Object();
  
  var instance1 = {
      Id: 0,
      customerName: "Khawaja Sardar",
      phoneNumber: "745-544-7777",
      address: "New York, NY",
      loanAmount: 5000,
      interest: 6.0,
      loanTermYears: 5,
      loanType: "APR",
      description: "Loan domain for instance1",
      calculatedLoanAmount: calculateAmount(instance1.loanAmount, instance1.interest, instance1.loanTermYears)
  
      }
  
  function calculateAmount(loanAmount, interest, loanTermYears) {
      var totalMonth = loanTermYears * 12;
      var montlyInterest = interest / 100 / 12;
      var temp = Math.pow(1 + montlyInterest, totalMonth);
      var monthlyPayment = loanAmount * montlyInterest * temp / (temp - 1);
      var sum =+ monthlyPayment * totalMonth
      var totalAmount = sum
  
      return totalAmount
      
  }
  
  info.push(instance1)
  
  console.log(info)</code></pre>
  </div>
  </div>
  </p>