Please post the HTML and Javascript must be able to run in
**Please post the HTML and Javascript - must be able to run in JS Fiddle (jsfiddle.net) - when using jsfiddle make sure to select \"no wrap in body\" or \"no wrap in head\" under the javascript settings***
***Must be built using a list, not an array***
Implement a Stack in Javascript (you will turn in a link to your program in JSFiddle). Do not use an array as the stack or in the implementation of the stack. Repeat - You MUST implement the Stack (start with your linked list) without the use of an array..
You will build a Stack Computer from your stack. When a number is entered it goes onto the top of the stack. When an operation is entered, the previous 2 numbers are operated on by the operation and the result is pushed onto the top of the stack. This is how an RPN calculator.
For example
2 [enter] 2
5 [enter] 5 2
* [enter] * 5 2 -> collapses to 10
would leave at 10 at the top of the stack.
The program should use a simple input box, either a text field or prompt and display the contents of the Stack.
Solution
I have written Stack functionality in JavaScript Using prototype.
// Creates a stack . Count variable is to store the count of elements and storage array is used to Store the elements.
var Stack = function() {
this.count = 0;
this.storage = {};
}
// Adds a value onto the end of the stack
//This can be processes by increasing the count of elements in the Array and push the element at the back of the Array.
Stack.prototype.push = function() {
var value = document.getElementByID(\"value\");
this.storage[this.count] = value;
//Increase the count of the elements in the Stack.
this.count++;
}
// Removes the value at the end of the Stack. This Function will also return Popped up element.
Stack.prototype.pop = function() {
// If the stack is empty we can\'t be able to remove the element so undefined.
if (this.count === 0) {
return undefined;
}
// Reduce the count of the number of Elements in the Array.
this.count--;
//Return the removed Element also
var result = this.storage[this.count];
delete this.storage[this.count];
return result;
}
// This function is useful for calculating the size of the Stack.
Stack.prototype.size = function() {
return this.count;
}

