adding bonus content for jest

This commit is contained in:
Ken
2019-03-04 11:36:08 -08:00
parent 6a15f0f6b6
commit 547e268bc8
15 changed files with 357 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
export class Stack<T> {
private _items: T[] = [];
/** Add an item to the top of the stack. */
push(item: T) {
this._items.push(item);
}
/** Remove the top item from the stack and return it. */
pop(): T {
if (this._items.length > 0) {
return this._items.pop();
}
}
/** Return the top item from the stack without removing it. */
peek(): T {
if (this._items.length > 0) {
return this._items[this._items.length - 1];
}
}
/** Get the number of items in the stack/ */
get count(): number {
return this._items.length;
}
}