January 2018
Intermediate to advanced
332 pages
7h 36m
English
To test the Stack we have just created, let's instantiate a new stack and call out each of the methods and take a look at how they present us with data:
var stack = new Stack();stack.push(10);stack.push(20);console.log(stack.items); // prints undefined -> cannot be accessed directlyconsole.log(stack.size()); // prints 2console.log(stack.peek()); // prints 20console.log(stack.pop()); // prints 20console.log(stack.size()); // prints 1stack.clear();console.log(stack.size()); // prints 0
When we run the above script we see the logs as specified in the comments above. As expected, the stack provides what appears to be the expected output at each stage of the operations.
Read now
Unlock full access