title: Creating A Tip Calculator In Typescript
body: <p>I've been trying to create a tip calculator where the user inputs their meal price.They then click a calculate button. What I want for my app to give back is a 15% tip and a total which is the original meal price plus the tip added on to it. I can't seem to get my function to work properly and I can't find anything else about this with typescript it is all on java and other coding languages.I'm not sure if I'm over complicating the function or just missing something small. Thanks for any and all feedback!  </p>
  
  <p>Index:
          
          
          
          
          
          
          </p>
  
  <pre><code>      &lt;div&gt;
           Enter Total Cost &lt;input id = "numbers" /&gt;
        &lt;br/&gt;&lt;br/&gt;
         Tip Amount: &lt;p id = "tip"/&gt;&lt;/p&gt;
         Total + Tip: &lt;p id = "total"/&gt;&lt;/p&gt;
         &lt;input value = "Calculate" onclick="calculate()" type = "button"/&gt;
  
  
       &lt;/div&gt;
  
      &lt;script src ="src/main.js"&gt;&lt;/script&gt;
  
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>Typecript:</p>
  
  <pre><code>  var numberInput:HTMLInputElement = &lt;HTMLInputElement&gt;document.getElementById("numbers");
  
    var numbertip:HTMLElement = &lt;HTMLInputElement&gt;document.getElementById("tip");
    var numbertotal: HTMLElement = &lt;HTMLInputElement&gt;document.getElementById("total");
  
    function calculate() {
  
    var numberinputString:String = numberInput.value.toString();
    var stringarray:string[] = numberinputString();
    var numberAarray:number[]=[];
  
  
    for(var i=0; i&lt;stringarray.length ; i++)
    {
      numberAarray[i]= parseFloat(stringarray[i]);
  
    }
  
    var tip:number=0;
    var total:number=0;
  
    for (var i =0; i&lt; numberAarray.length ;i++){
      total= total+ numberAarray[i];
  
    }
  
    numbertip.innerHTML=tip.toString();
    numbertotal.innerHTML=total.toString();
  
  
  
  }
  </code></pre>