 function LinkedList() {
   this.head = null;
 }

LinkedList.prototype.isEmpty = function(){
  return this.head === null;
};

// [10] -> [20] -> [30] -> null

LinkedList.prototype.size = function() {
  var current = this.head;
  var count = 0;

  while(current !== null){
    count++;
    current = current.next;
  }
  return count;
};

// [5]-> [10] -> [15] -> [20] -> null
// 1. Create a new node with value
// 2. Make the new node point to the current head
// 3. Update this.head to point to the new node
LinkedList.prototype.prepend = function(val){
  var newNode = {
    data: val,
    next: this.head
  };

  this.head = newNode;
};

// 1. Create a new new node using val
// 2. Traverse to the end of the list
// 3. Make the last node's 'next' value point to the new node

LinkedList.prototype.append = function(val) {
  var newNode = {
    data: val,
    next: null
  };

  if(this.isEmpty()){
    this.head = newNode;
    return;
  }

  var current = this.head;

  while(current.next !== null){
    current = current.next;
  }
  current.next = newNode;
};

LinkedList.prototype.contains = function(val){
  var current = this.head;

  while(current !== null){
    if(current.data === val){
      return true;
    }
    current = current.next;
  }
  return false;
}

// [5] -> [10] -> [15] -> [20] -> null
// prev  current
LinkedList.prototype.remove = function(val){
  if(this.contains(val)){
    return;
  }
  if(this.head.data === val){
    this.head = this.head.next;
    return;
  }

  var prev = null;
  var curr = this.head;

  while(curr.data !== val){
    prev = curr;
    curr = curr.next;
  }
  prev.next = curr.next;
};

// [5, 10, 15, 20]
LinkedList.prototype.print = function(){
  var output = '[';
  var current = this.head;

  while(current !== null){
    output += current.data;

    if(current.next !== null){
      output += ",";
    }
    current = current.next;
  }

  output += ']'
  console.log(output);
};

var list = new LinkedList();
list.append(10);
list.append(15);
list.append(20);
list.append(25);
list.prepend(5);
console.log(list.contains(10));
console.log(list.size());
console.log(list.isEmpty());
list.print();

@@ -1,53 +1,203 @@
- function LinkedList() %7B%0A   this.head = null;%0A %7D%0A
+// Create a linked list Object%0Afunction LinkedList() %7B%0A  // the function context has a null head as default%0A   this.head = null;%0A %7D%0A// add a function to the linked list object to check if it is empty
 %0ALin
@@ -236,16 +236,55 @@
 tion()%7B%0A
+  //  returns true if the head is null%0A
   return
@@ -2169,22 +2169,96 @@
 0);%0A
-list.append(15
+console.log(list);%0Alist.append(15);%0Aconsole.log(list);%0Alist.remove(15);%0Aconsole.log(list
 );%0Al
@@ -2303,24 +2303,43 @@
 prepend(5);%0A
+console.log(list);%0A
 console.log(
@@ -2423,12 +2423,586 @@
 st.print();%0A
+%0A// %7B head:%7B data: node1 , next: null%7D %7D%0A%0A// append a node - next equals new node%0A// %7B head:%7B data: node1 , next: %7B data: node2, next: null %7D %7D %7D%0A%0A// prepend a node - next equals head and new head equals new node%0A// %7B head2: %7B data: node2 , next: head1%7D %7D%0A%0A// remove a node - current.next == curernt.next.next and current equals current.next%0A// %7B head:%7B data: node1 , next: %7B data: node2, next: %7B data: node3, next: null %7D %7D %7D %7D%0A//              current                 current.next        current.next.next%0A// %7B head:%7B data: node1 , next: %7B data: node3, next: null %7D %7D %7D%0A//%0A

Add diagram notes