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
| 1. | What is JavaScript?, Variables, Data Structures & Naming Conventions |[Reading W1](/Week1/README.md)|[Homework W1](/Week1/MAKEME.md)|[Lesson Plan W1](/Week1/LESSONPLAN.md)|
67
67
| 2. | Statements vs. Expressions, Control flow, Loops, Operators, Conditional statement |[Reading W2](/Week2/README.md)|[Homework W2](/Week2/MAKEME.md)|[Lesson Plan W2](/Week1/LESSONPLAN.md)|
68
-
| 3. | Functions, Thinking like a programmer I, How JavaScript relates to HTML/CSS |[Reading W3](/Week3/README.md)|[Homework W3](/Week3/MAKEME.md)|[Lesson Plan W3](/Week1/LESSONPLAN.md)|
68
+
| 3. | Functions, Thinking like a programmer I, How JavaScript relates to HTML/CSS |[Reading W3](/Week3/README.md)|[Homework W3](/Week3/MAKEME.md)|[Lesson Plan W3](/Week3/LESSONPLAN.md)|
-`if (a > 4) { console.log("larger than 4"); } else { console.log("not larger than 4"); }`
51
+
42
52
### Exercise
43
53
44
54
#### Indicate for each of these whether it is an expression or a statement:
@@ -56,84 +66,106 @@ A statement is an instruction
56
66
#### Given the following code:
57
67
58
68
```js
59
-
let s ="Hello".toLowerCase();
69
+
let s ='Hello'.toLowerCase();
60
70
let l =s.length;
61
71
62
72
functionsum(a, b) {
63
73
return a + b;
64
74
}
65
-
letmax=function(a, b) {
75
+
letmax=function(a, b) {
66
76
return a > b ? a : b;
67
-
}
77
+
};
68
78
69
79
let s1 =sum(4, 5);
70
80
let s2 =4+5;
71
81
72
82
if (s2 == s1) {
73
-
console.log("same");
83
+
console.log('same');
74
84
} else {
75
-
console.log("not same");
85
+
console.log('not same');
76
86
}
77
87
```
78
88
79
-
List all 11 *statements* in the code above
80
-
List all 28 *expressions* in the code above (BONUS!)
89
+
List 5 statements from all 11 _statements_ in the code above
90
+
91
+
List 5 expressions of all 28 _expressions_ in the code above (BONUS!)
81
92
82
93
### Essence
94
+
83
95
It's important to know the difference between expressions and statement because:
84
-
1. It will give you an overview on what the code is about (is it an instruction or is code that resolves in a value)
85
-
2. While writing code you'll not mix up the two and therefore make sure that you do not write wrong code.
86
96
97
+
1. It will give you an overview on what the code is about (is it an instruction or is code that resolves to a value)
98
+
2. While writing code you'll not mix up the two and therefore make sure that you do not write wrong code.
87
99
88
100
## 3. What are operators (comparison, arithmetic, logical, assignment)
101
+
89
102
### Explanation
90
-
An operator is capable of manipulating a certain value or operand. Operators are used to perform specific mathematical and logical computations on operands. In other words, we can say that an operator operates the operands. In JavaScript operators are used for compare values, perform arithmetic operations etc. There are various operators supported by JavaScript:
91
-
92
-
* Arithmetic Operators
93
-
take numerical values (either literals or variables) as their operands and return a single numerical value.
94
-
* Comparison Operators
95
-
Two diferent types of comparison operators; They will always return a logical value,
96
-
- Equality Operators
97
-
checks if the operands are 'the same'
98
-
diffference in '=' '==' '==='
99
-
- Relational Operators
100
-
checks if the specific relation between two operands is true or false
101
-
102
-
* Logical Operators
103
-
Mostly 'comparing'boolean values, but it can be used with any type.
104
-
105
-
* Assignment Operators
106
-
assigns a value to its left operand based on the value of its right operand. The simple assignment operator is equal '='
Operators are very important in a programming language, because this is how we manipulate values.
115
-
In fact, operators are the buildingblocks of all possible actions.
116
134
135
+
### Essence
117
136
137
+
Operators are very important in a programming language, because this is how we manipulate values.
138
+
In fact, operators are the building blocks of all possible actions.
118
139
119
140
SECOND HALF (14.00 - 16.00)
120
141
121
142
## 4. What are loops (do/while & for loop)
143
+
122
144
### Explanation
123
-
Programming loops are about doing the same thing over and over again. Another term for that is: iteration
145
+
146
+
Programming loops are about doing the same thing over and over again, without typing the code over and over again. Another term for that is: iteration
124
147
125
148
Wikipedia: In most computer programming languages, a while loop is a (control flow) statement that allows (a block of) code to be executed repeatedly based on a given Boolean condition.
126
149
127
150
### Example
151
+
152
+
```javascript
153
+
```
154
+
128
155
### Exercise
156
+
129
157
Make a for loop with a do-while loop
158
+
130
159
### Essence
131
-
In programming you have to do a lot of (alomst) similar calculations over and over again. Using loops makes it iesier (and less boring) to code. Next to that it makes sure the the code is much more compact.
160
+
161
+
In programming you have to do a lot of (almost) similar calculations over and over again. Using loops makes it easier (and less boring) to code. Next to that it makes sure the the code is much more compact.
132
162
133
163
You can check: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Looping_code as well. underneath the paragraph: 'Why bother'
134
164
135
165
## 5. What are conditional statements (if/else & switch)
166
+
136
167
### Explanation
168
+
137
169
The normal order of execution of statements in a computer program is in straight-line order, from top to bottom. However, sometimes it is desirable to execute one or more statements conditionally, i.e. depending on whether some condition – determined by the state of your program – holds true (Boolean expression).
138
170
139
171
In its simplest form the `if` statement looks like this:
@@ -143,69 +175,88 @@ if () {
143
175
}
144
176
```
145
177
146
-
Then we have:
178
+
Then we have:
179
+
147
180
```js
148
181
if() {
149
182
} else {
150
183
}
151
184
```
185
+
152
186
At last we have:
187
+
153
188
```js
154
189
if() {
155
190
} elseif {
156
191
}
157
192
```
158
193
159
-
The switch statement can sometimes be a useful alternative to a concatenation of if statements. This is the case when the condition is an expression that can be decomposed into a number of distinct values or cases, as shown in the example below.
194
+
The switch statement can sometimes be a useful alternative to a long list of if statements. This is the case when the condition is an expression that can be decomposed into a number of distinct values or cases, as shown in the example below.
160
195
Depending on the value of the expression specified in the `switch` clause, one of the `case` statement blocks is executed. Each statement block should end with a `break` statement to ensure that a `case` doesn't 'fall through' into the next `case`.
161
196
162
197
The `default` statement at the end is executed when none of the preceding cases hold true. The `default` statement is not strictly required, but is a best practice to always specify one.
163
198
164
199
### Example
200
+
165
201
```js
166
202
if (distance <10) {
167
-
console.log('I will take the bike.');
203
+
console.log('I will take the bike.');
168
204
}
169
205
```
170
206
171
207
```js
172
208
consthyfModule='JavaScript-1';
209
+
let message ='';
173
210
174
211
switch (hyfModule) {
175
212
case'HTML/CSS':
176
-
console.log('In this module you will learn HTML and CSS.');
213
+
message ='In this module you will learn HTML and CSS.';
177
214
break;
178
215
case'JavaScript-1':
179
-
console.log('In this module you will learn Git and JavaScript basics.');
216
+
message ='In this module you will learn Git and JavaScript basics.';
180
217
break;
181
218
case'JavaScript-2':
182
-
console.log('In this module you will learn about JavaScript in the browser with HTML and CSS.');
219
+
message ='In this module you will learn about JavaScript in the browser with HTML and CSS.';
183
220
break;
184
221
case'JavaScript-3':
185
-
console.log('In this module you will learn about Async and API calls.');
222
+
message ='In this module you will learn about Async and API calls.';
186
223
break;
187
224
case'Node':
188
-
console.log('This module is about building server and CLI applications using Node.');
225
+
message ='This module is about building server and CLI applications using Node.';
189
226
break;
190
227
case'Database':
191
-
console.log('In this module is about Relational and Non-Relational Data and Database Systems.');
228
+
message ='In this module is about Relational and Non-Relational Data and Database Systems.';
192
229
break;
193
230
case'React':
194
-
console.log('In this module you will to build Single Page Applications using React.');
231
+
message ='In this module you will to build Single Page Applications using React.';
195
232
break;
196
233
case'Project':
197
-
console.log('In this final module you will do your graduation project.');
234
+
message ='In this final module you will do your graduation project.';
198
235
break;
199
236
default:
200
-
console.log('This module is unknown: '+ hyfModule);
201
-
}}
237
+
message ='This module is unknown: '+ hyfModule;
238
+
}
239
+
240
+
console.log(message);
202
241
```
203
242
243
+
### Exercise
204
244
245
+
Create a Switch/Case that will log the season based on the month.
0 commit comments