title: Javascript output incorrect
body: <p>This is my code</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 form = document.getElementById("addStudent");
  
  form.addEventListener("submit", function(event) {
    // Get form items
    var jerseyNumber = document.getElementById("jerseyNumber").value;
    var completions = document.getElementById("completions").value;
    var attempts = document.getElementById("attempts").value;
    var player = new Object();
    player.attempts = attempts;
    player.completions = completions;
    player.jerseyNumber = jerseyNumber;
  
    function percentage() {
      var e = ((player.completions / player.attempts) * 100);
      return e;
    }
  
    function showResults(event) {
      document.getElementById("results").innerHTML = "Freethrow Percentage for # " + player.jerseyNumber + " is " + percentage.e + "%";
    }
    showResults();
    resetForm(jerseyNumber, completions, attempts);
    event.preventDefault(); // Stop the form from submitting
  }, false);
  
  // Resets the form after it's submitted
  function resetForm(jerseyNumber, freethrowCompleted, freethrowAttempts) {
    jerseyNumber.value = "";
    freethrowCompleted.value = "";
    freethrowAttempts.value = "";
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>and the output is
  "Freethrow Percentage for # 23 is undefined%"</p>
  
  <p>and basically I have no idea why <code>e</code> is returning as <code>undefined</code>.</p>
  
  <p>And this is what im trying to do</p>
  
  <ol>
  <li>After the form is submitted, your program must create a JavaScript object to represent the player.  The object must have properties to contain their jersey number, their shooting attempts, and shooting completions.  The object must also contain a method that calculates the players free throw shooting percentage. Here's the formula: Math.round(completed / attempts * 100)</li>
  <li>You must then create a function called showResults() that takes this student object as an argument and displays the results on the screen in the div with id="results".  The example below uses this HTML: <code>&lt;h4&gt;Freethrow Percentage for #23: 94%&lt;/h4&gt;</code>.  The shooting percentage must be rounded to the nearest whole number (see formula above and screenshot below) with a percent symbol.</li>
  </ol>