Implemented Stack structure in Javacript. The purpose of working with these pre-written test cases is to get accustomed to the TDD cycle, and to get some ideas on what kind of tests to write.
Here are some links about TDD that i recommend:
- https://en.wikipedia.org/wiki/Test-driven_development
- https://talentgrid.io/test-driven-development-nedir/
- https://www.pluralsight.com/guides/introduction-to-test-driven-development-in-javascript
properties
- pop: number
- data: array
operations:
Push
→ Add an element to the stack.- data[top] = el
- top++
Pop
→ Delete an element from the stack.- !isEmpty
- top--
- data.pop()
- !isEmpty
Peek
→ Get the top element of the stack.- return data[top - 1]
Length
→ Return the length of the stack.- return top
isEmpty
→ Check if the stack is empty.- return top == 0
Print
→ Print the elements of the stack- log all the elements in data array