daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.     <head>
  3.         <script type="text/javascript" src="stack.js"></script>
  4.     </head>
  5.     <body>
  6.         <script type="text/javascript">
  7.         var mystack = new Stack();
  8.         var text = prompt("Enter some text", "");
  9.         for (var i = 0; i < text.length; i++) {
  10.             if (text.charAt(i) == '(') {
  11.                 mystack.push('(');
  12.             } else if (text.charAt(i) == ')') {
  13.                 try {
  14.                     mystack.pop();
  15.                 } catch (e) {
  16.                     alert(e);
  17.                 }
  18.             }
  19.         }
  20.         if (mystack.top != -1) {
  21.             alert("Stack not empty after traversing whole text!\n\n" +
  22.                 "Brackets don't match.");
  23.         }
  24.         </script>
  25.     </body>
  26. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top