"use strict";

// Create a stack class
function Stack() {
	this.top = null;
}

// push value into stack
Stack.prototype.push = function(val) {
	this.top = {
		data: val,
		next: this.top
	};
};

// pop value from stack
Stack.prototype.pop = function() {
	var top = this.top;
	if(top) {
		var popData = top.data;
		// next value becomes new top
		top = top.next;
		return popData;
	}
	return;
};


@@ -385,12 +385,240 @@
 return;%0A%7D;%0A%0A
+// test case%0Avar testStack = new Stack();%0AtestStack.push(1);%0AtestStack.push(2);%0AtestStack.push(3);%0AtestStack.push(4);%0A// expect to print out 4%0Aconsole.log(testStack.pop());%0A// expect to print out 3%0Aconsole.log(testStack.pop());%0A

Add test case for stack class program