"use strict";

// Program that sorts a stack such that smallest items are on top

// create 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;
		top = top.next;
		return popData;
	}
	return;
};

// sort stack in ascending order (main function in exercise)

@@ -483,8 +483,292 @@
 ercise)%0A
+Stack.prototype.sort = function() %7B%0A%09var stackTwo = new Stack();%0A%0A%09while(this.top) %7B%0A%09%09var placeHolder = this.pop();%0A%0A%09%09while(stackTwo.top && stackTwo.top.data %3E placeHolder) %7B%0A%09%09%09stackOne.push(stackTwo.pop());%0A%09%09%7D%0A%09%09stackTwo.push(placeHolder);%0A%09%7D%0A%09console.log(stackTwo);%0A%7D;%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A

Add sort stack function