Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array loop #156

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
deploy
  • Loading branch information
name committed Jul 27, 2022
commit 350bd0417ace96278f632c0c86a87855afbbf249
13 changes: 13 additions & 0 deletions linked list/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Linked Lists

In all programming languages, there are data structures. One of these data structures are called Linked Lists. There is no built in method or function for Linked Lists in Javascript so you will have to implement it yourself.

A Linked List is very similar to a normal array in Javascript, it just acts a little bit differently.

In this chapter, we will go over the different ways we can implement a Linked List.

Here's an example of a Linked List:

```
["one", "two", "three", "four"]
```
32 changes: 32 additions & 0 deletions linked list/add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Add

What we will do first is add a value to a Linked List.

```js
class Node {
constructor(data) {
this.data = data
this.next = null
}
}

class LinkedList {
constructor(head) {
this.head = head
}

append = (value) => {
const newNode = new Node(value)
let current = this.head

if (!this.head) {
this.head = newNode
return
}

while (current.next) {
current = current.next
}
current.next = newNode
}
}