Skip to content

This repository contains a simple implementation of a Stack data structure in JavaScript. The `Stack` class allows you to perform common stack operations like `push`, `pop`, `peek`, and check the stack size.

Notifications You must be signed in to change notification settings

aneesh-acharyeah/js-stack-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Stack Implementation Using Javascript

This repository contains a simple implementation of a Stack data structure in JavaScript. The Stack class allows you to perform common stack operations like push, pop, peek, and check the stack size.

Features

  • push(n): Add an element n to the top of the stack.
  • pop(): Remove and return the top element from the stack. If the stack is empty, it alerts the user.
  • peek(): View the top element without removing it.
  • size(): Get the number of elements currently in the stack.
  • is_empty(): Check if the stack is empty.

Stack Methods

Method Description
push(n) Adds element n to the top of the stack.
pop() Removes and returns the top element.
peek() Returns the top element without removing.
size() Returns the number of elements in stack.
is_empty() Checks if the stack is empty.

About

This repository contains a simple implementation of a Stack data structure in JavaScript. The `Stack` class allows you to perform common stack operations like `push`, `pop`, `peek`, and check the stack size.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published