title: brackets () in java script calculator?
body: <p>I have created a javascript calculator.this is an image of it</p>
  
  <p><a href="https://i.stack.imgur.com/gPKEQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gPKEQ.jpg" alt="enter image description here"></a></p>
  
  <p>But am facing a problem with brackets (). and the dot (.)</p>
  
  <p>what i want is that when i click on the bracket button first it will give me an open bracket then if i click again it should give a closing bracket and so on like in a normal calculator i want the program to know how to deal with brackets.</p>
  
  <pre><code>&lt;input type="text" id="t1" class="tt"&gt;
  &lt;input type="button" onClick="myFun6()" value="()"&gt;
  &lt;input type="button" onClick="myFun7()" value="."&gt;
  
  &lt;script&gt;
  function myFun6()
  {
  
  var prac = "()";
  document.getElementById("t1").value+=prac;
  
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>my second question is for the dot. i manged to get work but i still have an issue. if you click on the dot button if there was no element it will give "0." but if i click again the result will be "0.0." and so on.</p>
  
  <pre><code>function myFun7()
  {
  
  
  var d=document.getElementById("t1").value;
  
  if(d.length - 1)
  {
      d="0.";
      document.getElementById("t1").value+=d;
  }
  else
  {
      d=".";
      document.getElementById("t1").value+=d;
  }
  
  }
  
  </code></pre>