title: Creating a clear button code for a javascript calculator
body: <p>I have an assignment where I have to create a calculator using java script and HTML. I have coded enough that when I use the operators it will do the math, but the numbers will not show in the display box. I also am unsure on how to code the clear button and the negate button. 
  Here is the external javascript file.</p>
  
  <pre><code>    var mycalc = new calc(null,null,null);
      function calc(firstNum,secNum,operator)
      {
  this.firstNum = firstNum;
  this.secNum = secNum;
  this.operator = operator;
  }
  function numberClick(ref)
  {
  //alert.ref.value
  if(mycalc.firstNum == null)
      mycalc.firstNum = ref.value
  else if (mycalc.secNum == null)
      mycalc.secNum = ref.value //ref.value is the value from the input
  //alert("firstNum" + mycalc.operator.firstNum);
  //alert("secNum") + mycalc.secNum);
  }
  function operatorClick(ref)
  {
  if (mycalc.operator == null)
      mycalc.operator = ref.value;
  }
  function calculateResultClick()
  {
  if (mycalc.operator == "+")
  {
      var ans = parseInt(mycalc.firstNum) + parseInt(mycalc.secNum);
      alert(ans);
  }   
  if (mycalc.operator == "-")
  {
      var ans2 = parseInt(mycalc.firstNum) - parseInt(mycalc.secNum);
      alert(ans2);
  }   
  if (mycalc.operator == "*")
  {   
      var ans3 = parseInt(mycalc.firstNum) * parseInt(mycalc.secNum);
      alert(ans3)
  }
  if (mycalc.operator == "/")
  {
      var ans4 = parseInt(mycalc.firstNum) / parseInt(mycalc.secNum);
      alert(ans4)
  }
      }
       function Clear()
      {
  
      }
  </code></pre>