Clone the project from the starter.
Now that you've gone a bit deeper into understanding how arrays work in JavaScript, let's try to implement one on your own! Recall that the Array class includes the following:
- Properties:
- length
- Methods:
- read
- push
- pop
- shift
- unshift
- indexOf
- resize
For these exercises, you may not use any built-in JavaScript array methods.
You may use:
new Array(size)
to create new storage arraysarr[i]
to read/write elements by index
You must call resize whenever the size of your array exceeds the capacity.
To run tests
- Clone the starter and navigate to
dynamic-array
npm install
to install the test packagesnpm test
to run tests- Implement code in
dynamic-array.js
until all tests are green.
Tip: Reading test specs is key to understanding the problem.
- Identify the mechanics and complexity of adding and removing elements from an Array
- Solve the memory equation to retrieve data from an array
- Describe the resizing property of Dynamic Arrays and why it's needed
- Implement a Stack data structure using an array
- Select an Array or Stack when they are the appropriate tool for solving a problem