Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. remove(val){
  2. if(this.head === null) {
  3. return -1;
  4. }
  5. else if(this.head.val === val) {
  6. this.head = this.head.next;
  7. return 1;
  8. }
  9. let read = this.head;
  10. while(read.next !== null){
  11. if(read.next.val === val){
  12. read.next = read.next.next;
  13. return 1;
  14. }
  15. }
  16. return -1;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement