--- id: 587d8251367417b2b2512c62 title: Create a Linked List Class challengeType: 1 videoUrl: '' localeTitle: '' --- ## Description undefined ## Instructions undefined ## Tests
```yml tests: - text: '' testString: 'assert((function(){var test = new LinkedList(); return (typeof test.add === "function")}()), "Your LinkedList class should have a add method.");' - text: '' testString: 'assert((function(){var test = new LinkedList(); test.add("cat"); return test.head().element === "cat"}()), "Your LinkedList class should assign head to the first node added.");' - text: '' testString: 'assert((function(){var test = new LinkedList(); test.add("cat"); test.add("dog"); return test.head().next.element === "dog"}()), "The previous node in your LinkedList class should have reference to the newest node created.");' - text: '' testString: 'assert((function(){var test = new LinkedList(); test.add("cat"); test.add("dog"); return test.size() === 2}()), "The size of your LinkedList class should equal the amount of nodes in the linked list.");' ```
## Challenge Seed
```js function LinkedList() { var length = 0; var head = null; var Node = function(element){ this.element = element; this.next = null; }; this.head = function(){ return head; }; this.size = function(){ return length; }; this.add = function(element){ // Only change code below this line // Only change code above this line }; } ```
## Solution
```js // solution required ```