You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Here you can find course content and homework for the JavaScript 1,2 and 3 modul
11
11
|0.|Preparation for your first JavaScript session|[Pre-reading](https://github.com/HackYourFuture/JavaScript/tree/master/Week0) + [CLI Reading Week 1](https://github.com/HackYourFuture/CommandLine/blob/master/Lecture-1.md)|-|
12
12
|1.|• [CLI](https://github.com/HackYourFuture/CommandLine) session with Unmesh :heart: <br>• Intro JavaScript (What is it, where can you use it for)<br>• Variables [var, let, const]<br>• Basic Data types [Strings, Numbers, Arrays]<br>• Operators|[Reading Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/README.md)|[Homework Week 1](https://github.com/HackYourFuture/JavaScript/tree/master/Week1/MAKEME.md)|[Review](https://github.com/HackYourFuture/JavaScript/blob/master/Week1/REVIEW.md)|
|4.|• JSON<br>• Code debugging using the browser<br>• Functions + JSON/Arrays<br>• Code flow (order of execution) <br>• (capturing user input) <br>• Structuring code files|[Reading Week 4](https://github.com/HackYourFuture/JavaScript/tree/master/Week4)|[JS](https://github.com/HackYourFuture/JavaScript/tree/master/Week4/MAKEME.md) + [Git Homework Week 4](https://github.com/HackYourFuture/Git/blob/master/Lecture-1.md)|Review|
16
16
|5.|• First Git Session with Unmesh :smiling_imp:<br>• Events<br>• Callbacks <br>• XHTTP Requests <br>• API calls|[Reading Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5)|[Homework Week 5](https://github.com/HackYourFuture/JavaScript/tree/master/Week5/MAKEME.md)|Review|
17
17
|6.|• Second Git Session :see_no_evil:<br> • Async VS Sync<br>• Polling<br>• Structure for a basic SPA<br> TEST :boom:|[Reading Week 6](https://github.com/HackYourFuture/JavaScript/tree/master/Week6)|[Homework Week 6](https://github.com/HackYourFuture/JavaScript/tree/master/Week6/MAKEME.md)|Review|
Copy file name to clipboardExpand all lines: Week3/MAKEME.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,8 +5,7 @@
5
5
## Step 0 review:
6
6
- Go through the review of [the first week](https://github.com/HackYourFuture/JavaScript/blob/master/Week1/REVIEW.md) (Work in progress, update this week :wrench:)
7
7
- Go through the review of [the second week](https://github.com/HackYourFuture/JavaScript/blob/master/Week2/REVIEW.md) (work in progress, update this week :nut_and_bolt:)
8
-
- Daan will update the review of this week soon, keep an eye on that!
9
-
8
+
- Go through the review of [the third week](https://github.com/HackYourFuture/JavaScript/blob/master/Week3/REVIEW.md)
@@ -120,30 +120,30 @@ const f = new Array(20, 21) // result: [20, 21]
120
120
```
121
121
122
122
From value (as an example, many ways to create an array from another value):
123
-
```
123
+
```js
124
124
consta='hello world'// result: 'hello world'
125
125
constb=a.split('') // result: ['hello', 'world' ]
126
126
```
127
127
128
128
### Array length
129
129
Every array has as a 'static' property `length`. Meaning that we can easily get the amount of items in an array.
130
-
```
130
+
```js
131
131
constf= ['hi','there']
132
132
console.log(f.length) // 2
133
133
```
134
134
135
135
### Array index
136
136
We can access array elements through the position of the element in the array. This is called an index. Indices (plural of index) are 0-based, meaning that the first item's index is 0, the second element is 1.
137
137
138
-
```
138
+
```js
139
139
constx= ['first', 'second', 'third']
140
140
console.log(x[0]) // 'first'
141
141
142
142
x[3] ='fourth'
143
143
```
144
144
145
145
Note that arrays can have empty values. This should be avoided usually to prevent unexpected behaviour.
@@ -170,32 +170,32 @@ These methods are essential.
170
170
• [`.map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) creates a new array with the results of calling a provided function on every element in the calling array.
171
171
• [`.filter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) creates a new array with all elements that pass the test implemented by the provided function.
172
172
• [`.sort()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) sorts the elements of an array in place and returns the array
173
-
```
173
+
174
174
175
175
## Basic DOM manipulations
176
176
Using JavaScript we can access and manipulate the Document Object Model (DOM). We access the DOM through a global object called `document`.
177
177
178
178
HTML
179
-
```
179
+
```html
180
180
<body>
181
181
<divid="hello"></div>
182
182
</body>
183
183
```
184
184
185
185
A common method to access the DOM is by giving a HTML element an ID, and then using the `document` method `getElementById()`
186
186
187
-
```
187
+
```js
188
188
constx=document.getElementById('hello')
189
189
```
190
190
191
191
Now we have stored a *reference* of how that HTML element is accessed through the DOM object. We can use this to manipulate the element.
192
192
193
-
```
193
+
```js
194
194
x.innerHTML='hello'
195
195
```
196
196
197
197
We can also create elements
198
-
```
198
+
```js
199
199
consta=document.createElement('li')
200
200
x.appendChild(a)
201
201
```
@@ -207,13 +207,13 @@ First the straightforward part: how do we place comments in our code?
207
207
208
208
### JavaScript
209
209
Single line comments
210
-
```
210
+
```js
211
211
// Change heading:
212
212
document.getElementById("myH").innerHTML="My First Page";
213
213
```
214
214
215
215
Single line comments at end of the line:
216
-
```
216
+
```js
217
217
var x =5; // Declare x, give it the value of 5
218
218
```
219
219
@@ -222,7 +222,7 @@ Coding **well** in JavaScript: [JSDoc](http://usejsdoc.org/)
0 commit comments