remove_value(value){while(this.head&&this.head===value){// Special-casing the headthis.head=this.head.next}for(letnode=this.head;node.next;node=node.next){while(node.next===value){node.next=node.next.next}}}remove(i){if(i===0){// Still special-casing the head. If only JS had pointers...this.head=nullreturn}letnode=this.headfor(varj=0;j++;j<i-1){// Go just *before* the node we neednode=node.next}node.next=nullthis.length--}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It’s incredibly similar to the remove value!