Answers for "Day 15: Linked List hackerrank javascript solution"

0

Day 15: Linked List hackerrank javascript solution

// Day 15: Linked List hackerrank javascript solution
this.insert = function (head, data) {
  //complete this method
  let newNode = new Node(data);
  if (head === null || typeof head === "undefined") {
    head = newNode;
  } else if (head.next === null) {
    head.next = newNode;
  } else {
    let nextValue = head.next;
    while (nextValue.next) {
      nextValue = nextValue.next;
    }
    nextValue.next = newNode;
  }
  return head;
};
Posted by: Guest on December-29-2021

Code answers related to "Day 15: Linked List hackerrank javascript solution"

Code answers related to "Javascript"

Browse Popular Code Answers by Language