Stack and Queue classes?
We should also be able to find specific elements in our linked list. Traversing through data structures is something you'll want to get a lot of practice with! Let's create an indexOf method that takes an element as an argument, and returns that element's index in the linked list. If the element is not found in the linked list, return -1.
Let's also implement a method that does the opposite: an elementAt method that takes an index as an argument and returns the element at the given index. If no element is found, return undefined.
isEmpty method that checks if the linked list is empty, an indexOf method that returns the index of a given element, and an elementAt that returns an element at a given index.
LinkedList class should have a indexOf method.
testString: assert((function(){var test = new LinkedList(); return (typeof test.indexOf === 'function')}()), 'Your LinkedList class should have a indexOf method.');
- text: Your LinkedList class should have a elementAt method.
testString: assert((function(){var test = new LinkedList(); return (typeof test.elementAt === 'function')}()), 'Your LinkedList class should have a elementAt method.');
- text: Your size method should return the length of the linked list
testString: assert((function(){var test = new LinkedList(); test.add('cat'); test.add('dog'); test.add('kitten'); return test.size() === 3}()), 'Your size method should return the length of the linked list');
- text: Your indexOf method should return the index of the given element.
testString: assert((function(){var test = new LinkedList(); test.add('cat'); test.add('dog'); test.add('kitten'); return test.indexOf('kitten') === 2}()), 'Your indexOf method should return the index of the given element.');
- text: Your elementAt method should return at element at a given index.
testString: assert((function(){var test = new LinkedList(); test.add('cat'); test.add('dog'); test.add('kitten'); return test.elementAt(1) === 'dog'}()), 'Your elementAt method should return at element at a given index.');
```