Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 39345b4

Browse files
authored
Update LESSONPLAN.md
1 parent 5e8ad35 commit 39345b4

File tree

1 file changed

+150
-4
lines changed

1 file changed

+150
-4
lines changed

Week2/LESSONPLAN.md

Lines changed: 150 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,165 @@ FIRST HALF (12.00 - 13.30)
1616
1. Q&A about last week's concepts & homework
1717

1818
2. The difference between statements & expressions
19+
##### Explanation
20+
An expression is a piece of code that resolves in a value (becomes a value)
21+
22+
A statement is an instruction
23+
##### Example
24+
25+
###### Expressions
26+
* `sum(a, b)`
27+
* `a`
28+
* `a > 4 ? "yes" : "no"`
29+
* `a + b`
30+
* `a && b || c`
31+
32+
###### statements
33+
* `let x;`
34+
* `if (a > 4) { return "yes"; } else { return "no"; }`
35+
##### Exercise
36+
37+
###### 15. Indicate for each of these whether it is an expression or a statement:
38+
39+
1. `l`
40+
2. `l = 4;`
41+
3. `l == 4`
42+
4. `if (l == 4) { console.log("yes"); }`
43+
5. `console.log("yes");`
44+
6. `"yes"`
45+
7. `console.log(l == 4 ? "yes" : "no")`
46+
8. `function a() { return 4; }`
47+
9. `let a = function () { return 4; }`
48+
49+
###### Given the following code:
50+
51+
```js
52+
let s = "Hello".toLowerCase();
53+
let l = s.length;
54+
55+
function sum(a, b) {
56+
return a + b;
57+
}
58+
let max = function (a, b) {
59+
return a > b ? a : b;
60+
}
61+
62+
let s1 = sum(4, 5);
63+
let s2 = 4 + 5;
64+
65+
if (s2 == s1) {
66+
console.log("same");
67+
} else {
68+
console.log("not same");
69+
}
70+
```
71+
72+
**18. List all 11 *statements* in the code above**
73+
74+
**19. List all 28 *expressions* in the code above (BONUS!)**
75+
76+
##### Essence
77+
It's important to know the difference between expressions and statement because:
78+
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)
79+
2. While writing code you'll not mix up the two and therefore make sure that you do not write wrong code.
1980

20-
**Do Exercise**
2181

2282
3. What are operators (comparison, arithmetic, logical, assignment)
83+
##### Explanation
84+
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:
85+
86+
* Arithmetic Operators
87+
take numerical values (either literals or variables) as their operands and return a single numerical value.
88+
* Comparison Operators
89+
Two diferent types of comparison operators; They will always return a logical value,
90+
- Equality Operators
91+
checks if the operands are 'the same'
92+
diffference in '=' '==' '==='
93+
- Relational Operators
94+
checks if the specific relation between two operands is true or false
95+
96+
* Logical Operators
97+
Mostly 'comparing'boolean values, but it can be used with any type.
98+
99+
* Assignment Operators
100+
assigns a value to its left operand based on the value of its right operand. The simple assignment operator is equal '='
101+
102+
(https://www.geeksforgeeks.org/javascript-operators/)
103+
##### Example
104+
https://www.tutorialsteacher.com/javascript/javascript-operators
105+
##### Exercise
106+
See example
107+
##### Essence
108+
Operators are very important in a programming language, because this is how we manipulate values.
109+
In fact, operators are the buildingblocks of all possible actions.
110+
23111

24-
**Do Exercise**
25112

26113
SECOND HALF (14.00 - 16.00)
27114

28115
4. What are loops (do/while & for loop)
116+
##### Explanation
117+
Programming loops are about doing the same thing over and over again. Another term for that is: iteration
118+
119+
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.
29120

30-
**Do Exercise**
121+
##### Example
122+
*images*
123+
##### Exercise
124+
Make a for loop with a do-while loop
125+
##### Essence
126+
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.
127+
128+
You can check: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Looping_code as well. underneath the paragraph: 'Why bother'
31129

32130
5. What are conditional statements (if/else & switch)
131+
##### Explanation
132+
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.
133+
134+
In its simplest form the `if` statement looks like this:
135+
136+
137+
```js
138+
if () {
139+
}
140+
```
141+
142+
Then we have:
143+
```js
144+
if() {
145+
146+
} else {
147+
148+
}
149+
150+
151+
```
152+
```js
153+
if() {
154+
155+
} else if {
156+
157+
}
158+
```
159+
160+
Here, `condition` is a boolean expression that resolves to either `true` or `false` (or, more precisely, any expression that is 'truthy' or 'falsy', as will be explained later).
161+
162+
The statements within the curly braces `{` and `}` will be executed if the condition holds true, otherwise these statements will be skipped (i.e. ignored).
163+
164+
165+
166+
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.
167+
168+
##### Example
169+
```js
170+
if (distance < 10) {
171+
console.log('I will take the bike.');
172+
}
173+
```
174+
175+
176+
##### Exercise
177+
178+
179+
##### Essence
33180

34-
**Do Exercise**

0 commit comments

Comments
 (0)