• + 0 comments

    javascript solution:

    this.insert=function(head, data){
              //complete this method
              
              if(head == null){
                  return {data: data, next: null}
              }
                  let curr = head
                  while(curr !== null){
                      if(curr.next == null){
                        let newnode = {data: data, next: null}
                        curr.next = newnode
                        break
                      }
                      curr = curr.next
                  }
              return head   
        };