Skip to content

Conversation

patrick-plue
Copy link

When trying to delete the last node in a linked list, a type error occurred.
`TypeError: Cannot read properties of null (reading 'next')

  89 |         if (!excise) return null;
  90 |         node.next = excise.next;
> 91 |         if (!node.next.next) this.tail = node.next;
     |                        ^
  92 |         this.length--;
  93 |         return excise.value;
  94 |     }

  at LinkedList.delete (specs/arrays/linkedlist.solution.test.js:91:24)
  at Object.<anonymous> (specs/arrays/linkedlist.solution.test.js:173:9)`

I fixed this and added a test case for deleting the last node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant