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: fundamentals/conditional_execution.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ if (distance < 10) {
37
37
}
38
38
```
39
39
40
-
A condition can take more complex forms, using `&&` (logival AND) and `||` (logical OR) operators:
40
+
A condition can take more complex forms, using `&&` (logical AND) and `||` (logical OR) operators:
41
41
42
42
```js
43
43
if (distance <10&&!raining) {
@@ -70,16 +70,16 @@ if (distance < 10) {
70
70
if (raining) {
71
71
console.log('I will go public transportation.');
72
72
} else {
73
-
console.log('I will walk.');
73
+
console.log('I will walk.');
74
74
}
75
75
} else {
76
-
console.log('I will go by car.');
76
+
console.log('I will go by car.');
77
77
}
78
78
```
79
79
80
80
> As (nested) `if` statements can become quite complex it is very important that you indent your source code so that there can be no confusion about which statement blocks are executed for each condition, as was done in the examples.
81
81
82
-
>More informaton on MDN: [if...else](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
82
+
>More information on MDN: [if...else](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/if...else)
83
83
84
84
## The conditional (ternary) operator
85
85
@@ -91,7 +91,7 @@ The general format is:
91
91
condition ? expr1 : expr2
92
92
```
93
93
94
-
('ternary' means: _composed of three parts_)
94
+
('ternary' means: _composed of three parts_)
95
95
96
96
It is often used in combination with an assignment, as in this example:
97
97
@@ -108,7 +108,7 @@ It is **not** recommended to use the conditional operator if you do not intend t
108
108
age <1?console.log('new') :console.log('used');
109
109
```
110
110
111
-
>More informaton on MDN: [Conditional (ternary) Operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator)
111
+
>More information on MDN: [Conditional (ternary) Operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator)
112
112
113
113
## The switch statement
114
114
@@ -151,11 +151,11 @@ Depending on the value of the expression specified in the `switch` clause, one o
151
151
152
152
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.
153
153
154
-
>More informaton on MDN: [switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)
154
+
>More information on MDN: [switch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)
155
155
156
156
## truthy, falsy
157
157
158
-
**truthy**: 'sort of' `true`
158
+
**truthy**: 'sort of' `true`
159
159
**falsy**: 'sort of' `false`
160
160
161
161
From MDN:
@@ -182,4 +182,4 @@ if (x) {
182
182
}
183
183
```
184
184
185
-
>More informaton on MDN: [Truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), [Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
185
+
>More information on MDN: [Truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), [Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
Copy file name to clipboardExpand all lines: fundamentals/javascript_review.md
+34-34Lines changed: 34 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,14 @@
2
2
3
3
You'll need to know the following before starting the Node class (remember Node is just JavaScript in a different environment - and you KNOW JS already - right?!?!)
4
4
5
-
```
5
+
```
6
6
From Jason:
7
-
jason [9:11 AM]
7
+
jason [9:11 AM]
8
8
@timirkaria the most important topics will be sync/async and ajax. That and basic syntax (named and anonymous functions, callbacks, scope) should be sufficient!
9
9
```
10
10
11
11
### AJAX
12
-
Stands for *A*syncrhonous*J*avascript *A*nd *X*ml (think of XML as the old JSON) but now it's AJA*J* but that doesn't sound as good.
12
+
Stands for *A*synchronous*J*avascript *A*nd *X*ml (think of XML as the old JSON) but now it's AJA*J* but that doesn't sound as good.
13
13
14
14
So here's an example of a SYNCHRONOUS request (it waits for the request to come back before continuing)
15
15
@@ -29,7 +29,7 @@ console.log('Made the request')
29
29
30
30
```
31
31
32
-
And here's an example of an ASYNCHRONOUS version of the same request as above. Look carefully at the output.
32
+
And here's an example of an ASYNCHRONOUS version of the same request as above. Look carefully at the output.
Tell the request object what function to call when when the contents of the request are loaded. Inside the ANONYMOUS function which takes a parameter `e` we check the response code from the request (this is just HTTP stuff - nothing special). If the reponse code is good (200) then we print what we got.
60
+
Tell the request object what function to call when when the contents of the request are loaded. Inside the ANONYMOUS function which takes a parameter `e` we check the response code from the request (this is just HTTP stuff - nothing special). If the response code is good (200) then we print what we got.
61
61
62
-
More interesting is the order of the print statements. In the first example we saw the message `Received the response`**BEFORE** we saw the `Made the request` message because the program waited to get the response and print it before continuing to run.
62
+
More interesting is the order of the print statements. In the first example we saw the message `Received the response`**BEFORE** we saw the `Made the request` message because the program waited to get the response and print it before continuing to run.
63
63
64
-
In this case we see the `Made the request` message before we see the response because the program keeps running while waiting for the response. When the response is finally received it is printed before writing the `Received the response` to the console.
64
+
In this case we see the `Made the request` message before we see the response because the program keeps running while waiting for the response. When the response is finally received it is printed before writing the `Received the response` to the console.
65
65
66
66
Note that we used an anonymous function here - it has no name. There's nothing special about an anonymous function. We could equally use a named function in the above example:
67
67
@@ -80,7 +80,7 @@ function NOT_ANONYMOUS_ON_LOAD_FUNCTION(parameter) {
80
80
}
81
81
}
82
82
xhr.open("GET", SECRET_MESSAGE_URL, true);
83
-
xhr.onload=NOT_ANONYMOUS_ON_LOAD_FUNCTION; // Note: we are not CALLING the function - there are no ()
83
+
xhr.onload=NOT_ANONYMOUS_ON_LOAD_FUNCTION; // Note: we are not CALLING the function - there are no ()
84
84
// We'll leave the error function the way it is and you can change it to a named function
85
85
xhr.onerror=function (e) {
86
86
console.error(xhr.statusText);
@@ -90,14 +90,14 @@ console.log('Made the request');
90
90
91
91
```
92
92
93
-
### The big idea:
93
+
### The big idea:
94
94
95
-
#### Sync / Async
96
-
Make requests without waiting for the response and just get "notified" when the response happens. That's the asyncrhonous part - don't wait for it and stop everything else just let me know when it happens. How can the computer let you know? You tell it what to do when the async function is ready (has something to say - success or failure)
95
+
#### Sync / Async
96
+
Make requests without waiting for the response and just get "notified" when the response happens. That's the asynchronous part - don't wait for it and stop everything else just let me know when it happens. How can the computer let you know? You tell it what to do when the async function is ready (has something to say - success or failure)
97
97
98
98
#### Named and anonymous functions
99
-
Some functions have names and some don't. Sometimes you just want to use a function to pass it to another function so you don't need to name it. It never needs to be called outside of the function that you're passing it to so it doesn't need a name.
100
-
The simplest asynchonous function that you will see all over the place is called `setTimeout` (right now you should be reaching for a new tab and typing `MDN setTimeout` into Google). Be patient when running the below - it takes 3 seconds...
99
+
Some functions have names and some don't. Sometimes you just want to use a function to pass it to another function so you don't need to name it. It never needs to be called outside of the function that you're passing it to so it doesn't need a name.
100
+
The simplest asynchronous function that you will see all over the place is called `setTimeout` (right now you should be reaching for a new tab and typing `MDN setTimeout` into Google). Be patient when running the below - it takes 3 seconds...
What to do when the result of an async request is returned. Remember that requests can succeed as well as fail. Plan for (AND TEST) both.
131
131
132
132
#### Scope
133
-
I think we covered this pretty well with our discussion of closures in the last class but let me know if you need more.
133
+
I think we covered this pretty well with our discussion of closures in the last class but let me know if you need more.
134
134
135
135
## Recap
136
-
Read this - you may not understand it all but please read it before you read anything else about closures. The reason is that this is source material - this is the primary documentation. It is written very technically and in a bit of a boring way but there's a reason (as we talked about in class). The reason is to be clear so the language is precise and technical. It's OK if you don't get it now but just read it and it will stay in the back of your head.
136
+
Read this - you may not understand it all but please read it before you read anything else about closures. The reason is that this is source material - this is the primary documentation. It is written very technically and in a bit of a boring way but there's a reason (as we talked about in class). The reason is to be clear so the language is precise and technical. It's OK if you don't get it now but just read it and it will stay in the back of your head.
Copy file name to clipboardExpand all lines: fundamentals/loops.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
@@ -2,7 +2,7 @@
2
2
3
3
A loop is a programming construct to perform a repetitive action. Often (but not always) the repetitive action involves accessing or manipulating the individual elements of an array.
4
4
5
-
We will use the array of month names given below to illustrate the various types of loop constructs available in JavaScript. In the examples we will print out the names of the invidual months using a `console.log` statement.
5
+
We will use the array of month names given below to illustrate the various types of loop constructs available in JavaScript. In the examples we will print out the names of the individual months using a `console.log` statement.
0 commit comments