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-6Lines changed: 1 addition & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -39,12 +39,7 @@ If you have any questions or if something is not entirely clear ¯\\\_(ツ)\_/¯
39
39
| 1. | Document-Object Model (DOM), DOM manipulation |[Reading W1](/Week1/README.md)|[Homework W1](/Week1/MAKEME.md)|[Lesson Plan W1](/Week1/LESSONPLAN.md)|
40
40
| 2. | Synchronous vs. asynchronous, Event Loop, Callbacks, Array Functions |[Reading W2](/Week2/README.md)|[Homework W2](/Week2/MAKEME.md)|[Lesson Plan W2](/Week1/LESSONPLAN.md)|
41
41
| 3. | Scope, Hoisting, Closures, Thinking like a programmer II |[Reading W3](/Week3/README.md)|[Homework W3](/Week3/MAKEME.md)|[Lesson Plan W3](/Week1/LESSONPLAN.md)|
42
-
43
-
## Test
44
-
45
-
At the end of this module you'll be doing a formative test. It will be done on **paper** and will consist of **4 exercises** that will test your JavaScript1 and JavaScript2 knowledge.
46
-
47
-
Why on paper? Fundamental understanding should become intuitive. Only after having learned and mastered a concept deeply will you be able to use it creatively. If you rely too much on others, on Google or your code editor to do your thinking you'll make it very hard to cultivate the habit to think for yourself.
Copy file name to clipboardExpand all lines: Week2/MAKEME.md
+56-12Lines changed: 56 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,9 @@ console.log(doubleEvenNumbers(myNumbers)); // Logs "[4, 8]" to the console
38
38
39
39
The `doubleEvenNumbers` function returns only the even numbers in the array `myNumbers` and doubles them. Like you've learned in the [README](README.md), this block of code isn't easy to decipher.
40
40
41
-
Let's rewrite it. Using the `map` and `filter` functions, rewrite the `doubleEvenNumbers` function.
41
+
Let's rewrite it.
42
+
43
+
- Using the `map` and `filter` functions, rewrite the `doubleEvenNumbers` function.
42
44
43
45
**Exercise 2: What's your Monday worth?**
44
46
@@ -65,23 +67,65 @@ const mondayTasks = [
65
67
];
66
68
```
67
69
68
-
Write a program that computes how much Maartje has earned by completing these tasks, using `map` and `filter`.
70
+
Let's assume your hourly rate is €25. How much would you earn on that day?
69
71
70
-
For the 'summing part' you can try your luck with `reduce`; alternatively, you may use `forEach` or a `for` loop.
72
+
- Write a program that computes that:
73
+
- Use the `map` array function to take out the duration time for each task.
74
+
- Multiply each duration by a per-hour rate for billing and sum it all up.
75
+
- Output a formatted Euro amount, rounded to Euro cents, e.g: `€11.34`.
76
+
- Make sure the program can be used on any array of objects that contain a `duration` property with a number value
71
77
72
-
Follow these steps. Each step should build on the result of the previous step.
78
+
**Exercise 3: Lemon allergy**
73
79
74
-
- Map the tasks to durations in hours.
75
-
- Filter out everything that took less than two hours (i.e., remove from the collection)
76
-
- Multiply the each duration by a per-hour rate for billing (use €20/hour) and sum it all up.
77
-
- Output a formatted Euro amount, rounded to Euro cents, e.g: `€11.34`.
78
-
- Choose variable and parameters names that most accurately describe their contents or purpose. When naming an array, use a plural form, e.g. `durations`. For a single item, use a singular form, e.g. `duration`.
80
+
Your mom bought you a basket of fruit, because you're doing so well in HackYourFuture. How sweet of her!
Copy file name to clipboardExpand all lines: Week2/README.md
+28-18Lines changed: 28 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ These are the topics for week 2:
7
7
1. Synchronous vs. asynchronous
8
8
- Synchronous
9
9
- Asynchronous
10
-
- Why do we need asynchronicity?
11
10
2. Introducing asynchronicity using callbacks
12
11
- Higher order functions
13
12
- Functions as arguments to other functions
@@ -36,39 +35,52 @@ As you can see, each action is executed in a synchronous manner. This is to say:
36
35
37
36
### Asynchronous
38
37
39
-
Sometimes we want to do multiple things at the same time, without each action to be dependent on each other. Consider the following scenario:
38
+
Sometimes we want to do multiple things at the same time, without each action to be dependent on each other. Asynchronous execution avoids this bottleneck. You are essentially saying, “I know this function call is going to take a great deal of time, but my program doesn’t want to wait around while it executes.” Consider the following scenario:
40
39
41
40
> Wouter is feeling hungry, so he decides to go to a restaurant. He arrives there and gets into the line to order food. After ordering he takes a seat and, while he waits, reads a book. Occassionally he looks around and sees different things happening: new people enter the restaurant, some people get their food served and others are just talking. After a short while Wouter's food arrives and it's time to dig in!
42
41
43
42
In this example Wouter reads a book, but that doesn't affect his meal from being prepared. While his meal is prepared there are other people walking around, eating or just talking with each other. In short: multiple things are happening simultaneously and every event is not dependent upon another.
44
43
45
-
This does not happen by default in JavaScript, and needs to be invoked. A way to do that is by using `callbacks`, which you'll be learning about later.
44
+
This does not happen by default in JavaScript, and needs to be invoked. A way to do that is by using `callbacks`, which you'll be learning about in the next section.
46
45
47
-
## Why do we need asynchronicity?
46
+
## 2. Introducing asynchronicity using callbacks
48
47
49
-
In programming
48
+
Before we dive into what a `callback` is we have to understand a little about `higher order functions`.
50
49
51
-
This method of execution can have undesirable consequences. Suppose a function is called to start a time consuming process. What if you want to stop the lengthy process? With synchronous execution, your program is “stuck,” waiting for the process to end, with no way out.
50
+
### Higher order functions
52
51
53
-
Asynchronous execution avoids this bottleneck. You are essentially saying, “I know this function call is going to take a great deal of time, but my program doesn’t want to wait around while it executes.”
52
+
Let's start with a simple, practical definition: a higher order function is any function that can take another function as an argument or returns a function.
54
53
55
-
## 2. Introducing asynchronicity using callbacks
54
+
```js
55
+
// Example 1
56
+
functionhigherOrderFunction(anotherFunction) {
57
+
anotherFunction();
58
+
return;
59
+
}
56
60
57
-
In this example there is one process: life. In technical terms you could call it the program. Life contains many things, but in this example it only contains two things: you and your friend. Let's call them mini programs, or `functions`. The function called "You" does various things: studying, taking a break and having a snack.
61
+
// Example 2
62
+
functionanotherHigherOrderFunction() {
63
+
returnfunction() {
64
+
return;
65
+
};
66
+
}
67
+
```
58
68
59
-
This example illustrates the concept of **asynchronicity**: there are multiple processes happening simultaneously, without any single thing being dependent upon another. Your friend is not waiting by the phone until you have the answer. Or in technical terms: until the callback (which is you) has the return value (the asnwer to your friend's request to hang out).
69
+
Why do we need them? A higher order function integrates multiple functions, which each have a singular operational purpose. This will allow us to reuse code much more than if we had to write everything out.
60
70
61
-
###Higher order functions
71
+
>Higher order functions are a core concept within a programming paradigm called "functional programming". It's not relevant at all for you to know or care about this, but it's important to be exposed to it.
62
72
63
73
### Functions as arguments to other functions
64
74
65
75
Imagine the following situation:
66
76
67
77
> It's 15.00 and you're studying at home for an exam on the next day. Suddenly, your phone rings. You pick up and find it's your best friend! They ask if you'd like to hang out later. What do you do? On the one hand, you'd love to hang out have fun. On the other hand, you really should study some more. You don't know so you tell your friend that you're going to _call back_ later with your answer. You end the conversation and go back to studying. Maybe you take a break or have a snack as well. On the other line your friend hangs up the phone and continues along with their day: they go out grocery shopping, cleaning the house and cooking dinner. After finishing your studies you call your friend and makes plans to go out together.
68
78
69
-
**This is why callbacks are important: it allows us to introduce asynchronicity in the control flow of a program.**
79
+
This example illustrates the concept of **asynchronicity**: there are multiple processes happening simultaneously, without any single thing being dependent upon another. Your friend is not waiting by the phone until you have the answer. Or in technical terms: until the callback (which is you) has the return value (the answer to your friend's request to hang out).
70
80
71
-
A concrete example for why this might be useful is when you want to [TBC!!!]
81
+
This is the utility of `callbacks`: they allow us to introduce asynchronicity into the control flow of an application.
82
+
83
+
Let's put this into the context of a webpage.
72
84
73
85
Study the following resources to learn more about the importance of callbacks:
74
86
@@ -85,11 +97,9 @@ There are different ways of dealing with arrays. The most common way is by using
85
97
1. The first disadvantage is that using loops requires us to write custom logic for each use case. This can lead to repeated code, which we always want to [avoid](https://www.youtube.com/watch?v=IGH4-ZhfVDk)
86
98
2. The second disadvantage is that a loop isn't descriptive about what it intends to do. If another developer reads that code it wouldn't be obvious what it would do, without spending time on it to decipher it
87
99
88
-
There are certain functions, `array functions`, that aim to solve these two problems simultaneously.
89
-
90
-
Let's take an array function as an example: the `map()` function. It takes a function as an argument, and executes that unto each index position of the array, returning at the end a new array with all the "mapped" values.
100
+
There are certain functions, `array functions`, that aim to solve these two problems simultaneously. Array functions are higher order functions, because they take a function as an argument.
91
101
92
-
> Array functions are in general higher order functions, meaning they're functions that take a function as an argument.
102
+
Let's take an example: the `map()` function. It takes a function as an argument, and executes that unto each index position of the array, returning at the end a new array with all the "mapped" values.
93
103
94
104
Take a look at the following code snippet to see it in action:
95
105
@@ -141,7 +151,7 @@ In simple terms, the `Event Loop` is a mechanism that operates in the browser. I
141
151
1. Heap. This is where the browser assigns space in memory to each process
142
152
2. Call Stack. This is the amount of JavaScript commands (read: function calls and events) that need to be executed
143
153
3. Web APIs. These are objects (like the document) and functions (like XMLHttpRequest) that can be used within the JavaScript commands found in the Call Stack
144
-
4. Callback Queue. This is the
154
+
4. Callback Queue. This is the "waiting line" [ajksdbjkasbdjkasbnjkdbajksbdkj]
145
155
146
156
To see it in action check out the following resources:
Copy file name to clipboardExpand all lines: Week3/README.md
+24-7Lines changed: 24 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,13 @@ These are the topics for week 3:
12
12
- When does it happen
13
13
- Why do we need to know it?
14
14
3. Closures
15
+
- Execution context
16
+
- Defining a function within a function
15
17
4. Thinking like a programmer II
16
18
17
19
## 1. Scope
18
20
19
-
On of the central concepts in programming is the idea of `context`: the meaning of any particular thing is only determined in relation to its direct surroundings. Let's take language for example. If I say the following sentence:
21
+
One of the central concepts in programming is the idea of `context`: the meaning of any particular thing is only determined in relation to its direct surroundings. Let's take language for example. If I say the following sentence:
20
22
21
23
> I never said she stole my money.
22
24
@@ -32,30 +34,37 @@ Reading this it's not obvious how to interpret what the situation is about. Depe
32
34
33
35
It depends on `context` for me to know what really happened.
34
36
35
-
Let's draw the line to programming. Within any program there is a lot happening. But not everything is related to each other; some functions don't depend on other functions or variables
37
+
Let's draw the line to programming. Simply put, just like context gives meaning to a word, `scope` gives meaning to a variable/object.
36
38
37
-
`scope` has to do with "where we can access variables from"
39
+
The meaning is defined by whether or not the variable is accessible or not. If the variable is not within the scope
In any given application, there is usually one global scope. But there can be many local scopes
48
+
45
49
-[Understanding Scope in JavaScript](https://www.youtube.com/watch?v=SBjf9-WpLac)
46
50
-[Everything you wanted to know about JavaScript scope](https://ultimatecourses.com/blog/everything-you-wanted-to-know-about-javascript-scope)
47
51
48
52
### Const and let
49
53
50
-
Quick refresher: Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
54
+
> Quick refresher: Variables are used to store information to be referenced and manipulated in a computer program. They also provide a way of labeling data with a descriptive name, so our programs can be understood more clearly by the reader and ourselves. It is helpful to think of variables as containers that hold information. Their sole purpose is to label and store data in memory. This data can then be used throughout your program.
51
55
52
-
In JavaScript we define them using the keyword `var`:
56
+
In JavaScript we used to define variables using the keyword `var`:
53
57
54
58
```js
55
-
var
56
-
59
+
var myName ='Mohammed';
57
60
```
58
61
62
+
However
63
+
64
+
In programming, we generally want to keep things as simple as they can be. We even have a name for that: [KISS](https://thevaluable.dev/kiss-principle-explained/) (Keep it Simple, Stupid!)
65
+
66
+
-[How let and const are scoped in JavaScript](https://wesbos.com/javascript-scoping/)
67
+
59
68
## 2. Hoisting
60
69
61
70
If you look up the term "hoisting" in any dictionary, you'll find something like this:
@@ -82,6 +91,14 @@ Hoisting happens during `compile-time`.
82
91
83
92
Simply put, a closure is a function that is defined inside another function.
84
93
94
+
### Execution context
95
+
96
+
In your programming journey you'll learn that many concepts overlap one another.
97
+
98
+
An execution context is
99
+
100
+
### Defining a function within a function
101
+
85
102
For further study please check the following resources:
86
103
87
104
-[The Ultimate Guide to Execution Contexts, Hoisting, Scoping and Closures in JavaScript](https://www.youtube.com/watch?v=Nt-qa_LlUH0)
At the end of this module you’ll be doing a comprehension test on paper. Why on paper? Fundamental understanding should become intuitive. Only after having learned and mastered a concept deeply will you be able to use it creatively. If you rely too much on others, on Google or your code editor to do your thinking you'll make it very hard to cultivate the habit to think for yourself.
4
+
5
+
### Concepts
6
+
7
+
It will be about the most important JavaScript concepts you’ve learned about so far (JavaScript1 and JavaScript2). Here’s a list of all of them:
8
+
9
+
- Variables (const and let)
10
+
- Data types (strings, numbers, arrays, objects, booleans)
11
+
- Conditional statements (if/switch statement)
12
+
- Loops
13
+
- Regular and arrow functions
14
+
- How to use JavaScript to do basic DOM manipulations (add, modify and remove DOM elements)
15
+
- Code commenting
16
+
- Scope
17
+
- Array functions (map and filter)
18
+
- Callbacks
19
+
- Hoisting
20
+
21
+
### Purpose of the test
22
+
23
+
The purpose of this exam is to test your comprehension of JavaScript1 and JavaScript2 concepts.
24
+
25
+
- The goal for us is to know how solid your knowledge is and if you need any extra assistance throughout the program.
26
+
- The goal for you is to test how well enough you master the material so far.
27
+
28
+
Therefore, **you won’t be graded**. Like the homework you will get feedback and are expected to improve upon your weak points.
29
+
30
+
### Preparation
31
+
32
+
Here's general advice on how to optimally prepare:
33
+
34
+
- Make a list of every concept you currently don’t understand at all.
35
+
- Find out 2 things about each concept: (1) how does the basic structure look and (2) what is the most common use case.
36
+
- Ask questions through Slack to your teachers and/or your classmates
37
+
- Practice coding WITHOUT Google.
38
+
- Practice for understanding (why something is the case), NOT just for repetition’s sake (and hoping ‘you will understand it one day’).
39
+
- Stay calm, always
40
+
41
+
### Practical information
42
+
43
+
- The test will last about an hour
44
+
- It will be done on paper so please **bring a pencil and eraser**.
45
+
- There will be 4 questions, 2 for each module
46
+
47
+
Tip: if any of you need additional support, now is the moment to let us know as we can pair you up with someone to answer any questions you may have up until this point.
0 commit comments