title: javascript interactive stack which can push and pop using browser window
body: <p>I am trying to make an interactive stack application using javascript in browser but I cannot clear my console after every actions.</p>
  
  <pre><code> &lt;script&gt;
          var st1 = 10;
          var stk1 = new Array(10);
          var count = 0;
  
          function push1(v) {
              if (st1 === 0) {
                  rpiseconsole.log("Stack Overflow");
              }
  
              else {
                  st1 = st1 - 1;
                  stk1[st1] = v;
  
                  print1();
              }
          }
  
          function pop1() {
              var temp = stk1[st1];
  
              st1 = st1 + 1;
              print1();
              return temp;
          }
  
          function print1() {
              for (var i = st1; i &lt; 10; i++) {
                  rpiseconsole.log(stk1[i]);
              }
          };
  
          function doJob() {
              var x = document.getElementById("t").value;
  
              push1(x);
              document.getElementById("t").value = "";
          }
  
          function doJob1() {
              var p = pop1();
              document.getElementById("t1").value = p;
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>I am expecting that every time I click on the push button it will print the array of stack and clear the previous results in the console and when I click on the pop button it will take out the last data and print the remaining array into the textarea.</p>
  
  <p>I cannot get the clear option in console and I cannot output my array to the textarea in the same order as I put items into the stack.</p>