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

Skip to content

Commit 71ea72e

Browse files
committed
some small fixes in week3/lessonplan.md
1 parent 3ba32e5 commit 71ea72e

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

Week3/LESSONPLAN.md

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,43 @@ FIRST HALF (12.00 - 13.30)
2020
- Branching constructs
2121
- `if..else`
2222
- Looping constructs
23-
- `for`
24-
- `for..of`
25-
- `for..in`
26-
- `do..while`
23+
- `for`
24+
- `for..of`
25+
- `for..in`
26+
- `do..while`
2727
- Operators (arithmetic, comparison, eg `+`, `*`, `&&`, `||`, etc).
2828

29-
Note: You can ask students to explain a concept or summerise the last lecture themselves
29+
Note: You can ask students to explain a concept or summarize the last lecture themselves
3030

3131
## 2. Function (ES5 only)
3232

3333
### Explanation
34+
3435
Functions are a way to organize your code in to re-usable chunks.
3536

3637
> People think that computer science is the art of geniuses but the actual reality is the opposite, just many people doing things that build on each other, like a wall of mini stones.
3738
>
3839
> _-- Donald Knuth_
3940
4041
https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/functions.md
42+
4143
### Example
44+
4245
Same link as Explanation
46+
4347
### Exercise
4448

49+
Create a function that takes a string and returns the first letter of each word in the string.
50+
51+
```javascript
52+
firstLetter(`Hack Your Future`);
53+
// will return: 'HYF'
54+
```
55+
4556
### Essence
46-
- __Reusability__: Functions can be grouped together to make a module (or library), and then modules can be imported into your application so you can build awesome apps!
47-
- __Abstraction__: Hide underlying details about how a piece of functionality works under the hood. You can change how things are implemented within the function without other programmers who use your function worrying aobut the exact details of how it was implemented.
57+
58+
- **Reusability**: Functions can be grouped together to make a module (or library), and then modules can be imported into your application so you can build awesome apps!
59+
- **Abstraction**: Hide underlying details about how a piece of functionality works under the hood. You can change how things are implemented within the function without other programmers who use your function worrying about the exact details of how it was implemented.
4860

4961
And the same link as Explanation
5062

@@ -53,18 +65,19 @@ SECOND HALF (14.00 - 16.00)
5365
## 3. Scope (global, functional, block)
5466

5567
### Explanation
56-
Scopes define the visiblity of declarations of variables and functions.
5768

58-
The top level outside all your functions is called the _global scope_. Values defined in the global scope are accessible from everywhere in the code. Whereas, variables defined in local scope can only be accessed and altered inside the scope they were created.
69+
Scopes define the visibility of declarations of variables and functions.
70+
71+
The top level, outside all your functions, is called the _global scope_. Values defined in the global scope are accessible from everywhere in the code. Whereas, variables defined in local scope can only be accessed and altered inside the scope they were created.
5972

6073
- `var` and `function` declarations are visible with function scope.
61-
- `let` and `const` declarations are visible with block scope. A block can be seen as a set of statements enclosed in curly brackets({}).
74+
- `let` and `const` declarations are visible with block scope. A block can be seen as a set of statements enclosed in curly brackets(`{}`).
6275

6376
Global scope:
6477

6578
- Can be a real useful tool or a nightmare.
6679
- Useful in scenarios where we want to export JS modules, use third party libraries like jQuery etc.
67-
- Big risk of causing namespace clashes with multiple variables with same name being created in different places.
80+
- Big risk of causing problems called namespace clashes with multiple variables with same name being created in different places.
6881

6982
Local Scope:
7083

@@ -73,31 +86,35 @@ Local Scope:
7386
- Variables defined within a function aren't available outside it. They are created when a function starts and are _in a way_ destroyed/hidden when a function ends.
7487

7588
https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/scope.md
89+
7690
### Example
91+
7792
![Scopes](../assets/scopes.png)
7893

7994
```Javascript
80-
let villan = "Joker"; // | global scope
95+
let villain = "Joker"; // | global scope
8196
// |
8297
function myFunction() { // | | function scope
8398
let hero = "Batman"; // | |
8499
if (hero === "Batman") { // | | | block scope
85100
let coHero = "Robin"; // | | |
86101
console.log(hero); // | | |
87102
console.log(coHero); // | | |
88-
console.log(villan); // | | |
103+
console.log(villain); // | | |
89104
} // | | |
90105
console.log("------") // | |
91106
console.log(hero); // | |
92107
console.log(coHero); // | |
93-
console.log(villan); // | |
108+
console.log(villain); // | |
94109
} // | |
95110
// |
96111
myFunction(); // |
97112
```
98113

99-
And the same link as Explanation
114+
And the same link as Explanation
115+
100116
### Exercise
117+
101118
What happens if we use the same variable name in different scopes?
102119

103120
```Javascript
@@ -112,15 +129,21 @@ function myFunction() {
112129

113130
myFunction();
114131
```
132+
115133
### Essence
134+
116135
Same link as Explanation
117136

118137
## 4. How to combine variables, loops & functions
119138

120139
### Explanation
140+
121141
### Example
142+
122143
### Exercise
144+
123145
https://github.com/yash-kapila/HYF-JS1-Week3/tree/master/src
146+
124147
### Essence
125148

126149
_Special thanks to Jim Cramer, Yash Kapila, David Nudge for most of the content_

0 commit comments

Comments
 (0)