Skip to content

Instantly share code, notes, and snippets.

@urstory
Created September 17, 2015 07:55
Show Gist options
  • Save urstory/63cb94c9cbda90c44a98 to your computer and use it in GitHub Desktop.
Save urstory/63cb94c9cbda90c44a98 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script>
function Stack(){
this.array = new Array();
this.push = function(element){
this.array.push(element);
}
this.pop = function(){
return this.array.pop();
}
this.isEmpty = function(){
if(this.array.length == 0)
return true;
else
return false;
}
}
var stack = new Stack();
stack.push('hello');
stack.push('world');
stack.push('!!!');
if(!stack.isEmpty()){
alert(stack.pop());
}
if(!stack.isEmpty()){
alert(stack.pop());
}
if(!stack.isEmpty()){
alert(stack.pop());
}
if(!stack.isEmpty()){
alert(stack.pop());
}else{
alert("empty!!!!");
}
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment