frontend-challenges icon indicating copy to clipboard operation
frontend-challenges copied to clipboard

91 - Stack - javascript

Open jsartisan opened this issue 1 year ago • 0 comments

index.js

class Stack {
  constructor() {
    this.items = [];
  }

  size() {
    return this.items.length;
  }

  peek() {
    return this.items.at(-1);
  }

  push(item) {
    return this.items.push(item);
  }

  pop() {
    return this.items.pop();
  }

  isEmpty() {
    return this.size() === 0;
  }
}

export { Stack };

jsartisan avatar Jun 24 '24 12:06 jsartisan