The spec for the removeFromTail method seems to have an error.
This Mocha frame (line 199 - 206):
it('Should reassign the new tail\'s next pointer to null', () => { linkedList.addToTail('A'); linkedList.addToTail('B'); linkedList.addToTail('C'); expect(linkedList.head.next.next).to.eql({ value: 'C', next: null }); linkedList.removeFromTail(); expect(linkedList.head.next.next).to.eql(null); });
specifically the assertions from line 203 to line 205; if the 'C' node's next value is NULL, calling the linkedList.removeFromTail() method would .pop() the 'C' node from the linked list and assign the 'B' node's next value NULL. The last assertion expect(linkedList.head.next.next).to.eql(null);
ex.
[original]: A(.next.next.next = null) -> B(.next.next = null) -> C(.next = null) -> null
[tail removed]: A(.next.next = null) -> B(.next = null) -> null -> ???
The spec for the removeFromTail method seems to have an error.
This Mocha frame (line 199 - 206):
it('Should reassign the new tail\'s next pointer to null', () => { linkedList.addToTail('A'); linkedList.addToTail('B'); linkedList.addToTail('C'); expect(linkedList.head.next.next).to.eql({ value: 'C', next: null }); linkedList.removeFromTail(); expect(linkedList.head.next.next).to.eql(null); });specifically the assertions from line 203 to line 205; if the 'C' node's next value is
NULL, calling thelinkedList.removeFromTail()method would.pop()the 'C' node from the linked list and assign the 'B' node's next valueNULL. The last assertionexpect(linkedList.head.next.next).to.eql(null);ex.
[original]: A(.next.next.next = null) -> B(.next.next = null) -> C(.next = null) -> null
[tail removed]: A(.next.next = null) -> B(.next = null) -> null -> ???