Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*getMiddleElement() {
- let node = this.head;
- let count = 1;
- const half = Math.floor(this.length / 2);
- while (node) {
- if (count === half) return `${node.value} is the middle element!`;
- count++;
- node = node.next;
- }
- return node;
- } */
Add Comment
Please, Sign In to add comment