> For the complete documentation index, see [llms.txt](https://betwinsouls.gitbook.io/full-stack-javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://betwinsouls.gitbook.io/full-stack-javascript/data_structures/linded_list/manipulating_the_linked_list/singly_linked_list.md).

# Singly Linked List

```
function Node(element) {
  this.element = element;
  this.next = null;
}

function LList() {
  this.head = new Node("head");
  this.find = find;
  this.insert = insert;
  this.display = display;
}

function find(item) {
var currNode = this.head;
while (currNode.element != item) {
      currNode = currNode.next;
   }
return currNode;
}

function insert(newElement, item) {
  var newNode = new Node(newElement);
  var current = this.find(item);
  newNode.next = current.next;
  current.next = newNode;
}

function display() {
var currNode = this.head;
while (currNode.next !== null) {
      console.log(currNode.next.element);
      currNode = currNode.next;
   }
}


var cities = new LList();
cities.insert("Seattle", "head");
cities.insert("Portland", "Seattle");
cities.insert("Boulder", "Portland");
cities.display();
```
