--- id: 587d8250367417b2b2512c5f title: Create a Stack Class challengeType: 1 videoUrl: '' localeTitle: '' --- ## Description undefined ## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert((function(){var test = new Stack(); return (typeof test.push === "function")}()), "Your Stack class should have a push method.");' - text: '' testString: 'assert((function(){var test = new Stack(); return (typeof test.pop === "function")}()), "Your Stack class should have a pop method.");' - text: '' testString: 'assert((function(){var test = new Stack(); return (typeof test.peek === "function")}()), "Your Stack class should have a peek method.");' - text: '' testString: 'assert((function(){var test = new Stack(); return (typeof test.isEmpty === "function")}()), "Your Stack class should have a isEmpty method.");' - text: '' testString: 'assert((function(){var test = new Stack(); return (typeof test.clear === "function")}()), "Your Stack class should have a clear method.");' - text: '' testString: 'assert((function(){var test = new Stack(); test.push("CS50"); return (test.peek() === "CS50")}()), "The peek method should return the top element of the stack");' - text: '' testString: 'assert((function(){var test = new Stack(); test.push("CS50"); return (test.pop() === "CS50");}()), "The pop method should remove and return the top element of the stack");' - text: '' testString: 'assert((function(){var test = new Stack(); return test.isEmpty()}()), "The isEmpty method should return true if a stack does not contain any elements");' - text: '' testString: 'assert((function(){var test = new Stack(); test.push("CS50"); test.clear(); return (test.isEmpty())}()), "The clear method should remove all element from the stack");' ```
## Challenge Seed
```js function Stack() { var collection = []; this.print = function() { console.log(collection); }; // Only change code below this line // Only change code above this line } ```
## Solution
```js // solution required ```