From 350bd0417ace96278f632c0c86a87855afbbf249 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 27 Jul 2022 13:25:16 -0700 Subject: [PATCH 01/16] deploy --- linked list/README.md | 13 +++++++++++++ linked list/add.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 linked list/README.md create mode 100644 linked list/add.md diff --git a/linked list/README.md b/linked list/README.md new file mode 100644 index 00000000..c5a9dcc3 --- /dev/null +++ b/linked list/README.md @@ -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"] +``` diff --git a/linked list/add.md b/linked list/add.md new file mode 100644 index 00000000..cc920440 --- /dev/null +++ b/linked list/add.md @@ -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 + } +} From 5462a898cbac8fce80b4b98badb65aa1c06c49e3 Mon Sep 17 00:00:00 2001 From: name Date: Thu, 28 Jul 2022 19:28:30 -0700 Subject: [PATCH 02/16] deploy --- arrays/push.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 arrays/push.md diff --git a/arrays/push.md b/arrays/push.md new file mode 100644 index 00000000..e63fc63c --- /dev/null +++ b/arrays/push.md @@ -0,0 +1,10 @@ +# Push + +You can push certain items to an array making the last index the item you just added. + +```javascript +var array = [1, 2, 3]; + +array.push(4); + +console.log(array); From 0b51eb1eee50c1f0a7d86fe42ffffe40bf0c3220 Mon Sep 17 00:00:00 2001 From: name Date: Thu, 28 Jul 2022 19:33:04 -0700 Subject: [PATCH 03/16] deploy --- arrays/shift.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 arrays/shift.md diff --git a/arrays/shift.md b/arrays/shift.md new file mode 100644 index 00000000..64e01319 --- /dev/null +++ b/arrays/shift.md @@ -0,0 +1,10 @@ +# Shift + +What Shift does to an array is delete the first index of that array and move all indexes to the left. + +```javascript +var array = [1, 2, 3]; + +array.shift(); + +console.log(array); From cd87196b59fb56ba43b61f9fa53d78f8ec294aef Mon Sep 17 00:00:00 2001 From: name Date: Fri, 5 Aug 2022 12:12:50 -0700 Subject: [PATCH 04/16] deploy --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b5a5a635..ec2574e1 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,6 @@ This book will teach you the basics of programming and Javascript. Whether you a ![](./assets/intro.png) -JavaScript (_JS for short_) is the programming language that enables web pages to respond to user interaction beyond the basic level. It was created in 1995, and is today one of the most famous and used programming languages. +JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. + +Do not confuse JavaScript with the Java programming language. Both "Java" and "JavaScript" are trademarks or registered trademarks of Oracle in the U.S. and other countries. However, the two programming languages have very different syntax, semantics, and use. From ae54f4ccfd6a423a62b1f6a57b09a71edf2eb2e2 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 17 Aug 2022 15:43:44 -0700 Subject: [PATCH 05/16] deploy --- arrays/methods.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 arrays/methods.md diff --git a/arrays/methods.md b/arrays/methods.md new file mode 100644 index 00000000..7c6e7eeb --- /dev/null +++ b/arrays/methods.md @@ -0,0 +1,10 @@ +# Methods + +Using methods on an array alters an array in some sort of way. + +```javascript +var array = [1, 2, 3]; + +array = array.join(''); + +console.log(array); From 58db6935e50d3cdaef1802e5474861c3e87b9f7f Mon Sep 17 00:00:00 2001 From: name Date: Mon, 12 Sep 2022 07:13:21 -0700 Subject: [PATCH 06/16] deploy --- arrays/looping.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 arrays/looping.md diff --git a/arrays/looping.md b/arrays/looping.md new file mode 100644 index 00000000..6e2111cd --- /dev/null +++ b/arrays/looping.md @@ -0,0 +1,11 @@ +#Looping + +With Looping, you can access any point in an array with an increment, making you go through every item in the array. + +```javascript +var array = [1, 2, 3, 4, 5]; + +for (let i = 0; i < array.length(); i++) +{ + console.log(array[i]); +} From 2eac09db143176f6051ea22d6a37081d1e4bce3c Mon Sep 17 00:00:00 2001 From: name Date: Wed, 14 Sep 2022 09:28:23 -0700 Subject: [PATCH 07/16] deploy --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index ec2574e1..f8384bdf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,12 @@ This book will teach you the basics of programming and Javascript. Whether you a ![](./assets/intro.png) +JavaScript is the world's most popular programming language. + +JavaScript is the programming language of the Web. + +JavaScript is easy to learn. + JavaScript, often abbreviated JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. Do not confuse JavaScript with the Java programming language. Both "Java" and "JavaScript" are trademarks or registered trademarks of Oracle in the U.S. and other countries. However, the two programming languages have very different syntax, semantics, and use. From f8353b6da98c23e15ff4a2a5aa4a9fc14283c7db Mon Sep 17 00:00:00 2001 From: name Date: Wed, 21 Sep 2022 16:15:23 -0700 Subject: [PATCH 08/16] deploy --- arrays/spread.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 arrays/spread.md diff --git a/arrays/spread.md b/arrays/spread.md new file mode 100644 index 00000000..e6576ac4 --- /dev/null +++ b/arrays/spread.md @@ -0,0 +1,8 @@ +#Spread Operator + +With the Spread Operator, it allows us to quickly copy all or part of an existing array or object into another array or object. + +```javascript +var arr = [1, 2, 3, 4, 5]; + +console.log(...arr); From 94ce2fae525d6dc877b5217c8aab022ac4e62894 Mon Sep 17 00:00:00 2001 From: name Date: Mon, 26 Sep 2022 08:18:28 -0700 Subject: [PATCH 09/16] array-join --- arrays/join.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 arrays/join.md diff --git a/arrays/join.md b/arrays/join.md new file mode 100644 index 00000000..077dcc19 --- /dev/null +++ b/arrays/join.md @@ -0,0 +1,8 @@ +#Joining + +The .Join() method, makes an array turn into a string and joining it all together. + +```javascript +var array ["one", "two", "three", "four"]; + +console.log(array.join(" ")); \ No newline at end of file From c60259a82bf0b90cef422518449bfe19da09e83f Mon Sep 17 00:00:00 2001 From: name Date: Fri, 21 Oct 2022 23:01:28 -0700 Subject: [PATCH 10/16] deploy --- arrays/foreach.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 arrays/foreach.md diff --git a/arrays/foreach.md b/arrays/foreach.md new file mode 100644 index 00000000..e3669711 --- /dev/null +++ b/arrays/foreach.md @@ -0,0 +1,8 @@ +#Looping with Foreach + +The forEach() method executes a provided function once for each array element. + +```javascript +var arr = ["one", "two", "three"]; + +arr.forEach(e => console.log(e)); From b041c7e45a444e362f27fa8076909a5d35625c4f Mon Sep 17 00:00:00 2001 From: name Date: Mon, 31 Oct 2022 16:13:12 -0700 Subject: [PATCH 11/16] pop --- arrays/pop.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 arrays/pop.md diff --git a/arrays/pop.md b/arrays/pop.md new file mode 100644 index 00000000..cfc44fb3 --- /dev/null +++ b/arrays/pop.md @@ -0,0 +1,10 @@ +# Pop + +The pop() method removes the last element from an array and returns that element. This method changes the length of the array. + +```javascript +var arr = ["one", "two", "three", "four", "five"]; + +arr.pop(); + +console.log(arr); From c629ced6ddba4f8a424831d9f6d62ccf3f24da2f Mon Sep 17 00:00:00 2001 From: name Date: Wed, 2 Nov 2022 06:30:17 -0700 Subject: [PATCH 12/16] prepend-linked-list --- linked list/prepend.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 linked list/prepend.md diff --git a/linked list/prepend.md b/linked list/prepend.md new file mode 100644 index 00000000..192479ea --- /dev/null +++ b/linked list/prepend.md @@ -0,0 +1,29 @@ +# 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 + } + + prepend = (value) => { + const newNode = new Node(value) + + if (!this.head) { + this.head = newNode + } + else { + newNode.next = this.head + this.head = newNode + } + } +} \ No newline at end of file From 23b24011d3888a767557cd67c099cc7ced20ac55 Mon Sep 17 00:00:00 2001 From: name Date: Thu, 3 Nov 2022 16:13:43 -0700 Subject: [PATCH 13/16] boolean-chapter --- boolean/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 boolean/README.md diff --git a/boolean/README.md b/boolean/README.md new file mode 100644 index 00000000..0eb4e269 --- /dev/null +++ b/boolean/README.md @@ -0,0 +1,16 @@ +# Boolean + +A JavaScript Boolean represents one of two values: true or false. + +```javascript +var equalsHeads = false; + +if (equalsHeads === true) +{ + console.log("coin is heads"); +} + +else if (equalsHeads === false) +{ + console.log("coin is tails"); +} From cf4a2a31bb4dd36c8e1af288e43e72d8fdb39886 Mon Sep 17 00:00:00 2001 From: name Date: Tue, 8 Nov 2022 16:00:30 -0700 Subject: [PATCH 14/16] linked-list-pop --- linked list/pop.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 linked list/pop.md diff --git a/linked list/pop.md b/linked list/pop.md new file mode 100644 index 00000000..33579c36 --- /dev/null +++ b/linked list/pop.md @@ -0,0 +1,25 @@ +# Pop + + +```js +class Node { + constructor(data) { + this.data = data + this.next = null + } +} + +class LinkedList { + constructor(head) { + this.head = head + } + + pop = () => { + let current = this.head + + while (current.next.next) { + current = current.next + } + current.next = current.next.next + } +} \ No newline at end of file From 5c65668ebefd78f6de43a13e81b0f82a081ada81 Mon Sep 17 00:00:00 2001 From: name Date: Tue, 8 Nov 2022 16:05:03 -0700 Subject: [PATCH 15/16] array-pop --- arrays/foreach.md | 2 +- arrays/sort.md | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 arrays/sort.md diff --git a/arrays/foreach.md b/arrays/foreach.md index e3669711..23bf7d2b 100644 --- a/arrays/foreach.md +++ b/arrays/foreach.md @@ -1,4 +1,4 @@ -#Looping with Foreach +# Looping with Foreach The forEach() method executes a provided function once for each array element. diff --git a/arrays/sort.md b/arrays/sort.md new file mode 100644 index 00000000..f88e3da5 --- /dev/null +++ b/arrays/sort.md @@ -0,0 +1,10 @@ +# Sorting an Array + +The sort() method sorts the items of an array in a specific order (ascending or descending). + +```javascript +var city = ["California", "Barcelona", "Paris", "Kathmandu"]; + +var sortedArray = city.sort(); + +console.log(sortedArray); From f5f9fde537930679cb321f3d041ad6c1ce46281f Mon Sep 17 00:00:00 2001 From: name Date: Tue, 22 Nov 2022 05:54:19 -0700 Subject: [PATCH 16/16] deploy --- linked list/shift.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 linked list/shift.md diff --git a/linked list/shift.md b/linked list/shift.md new file mode 100644 index 00000000..f52f75d0 --- /dev/null +++ b/linked list/shift.md @@ -0,0 +1,21 @@ +# Shift + +What we will do first is remove the first element of the Linked List. + +```js +class Node { + constructor(data) { + this.data = data + this.next = null + } +} + +class LinkedList { + constructor(head) { + this.head = head + } + + shift = () => { + this.head = this.head.next + } +}