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
"description":"Practice refactoring with ES2015 features."
5
+
},
6
+
"chapters": [
7
+
{
8
+
"title":"Declaring Variables",
9
+
"description":"Using `let` & `const`.",
10
+
"pages": [
11
+
{
12
+
"title":"Let",
13
+
"description":"`let` allows you to declare variables that are limited in scope to the block, statement, or expression on which it is used.\n\nThis is unlike the `var` keyword, which defines a variable globally, or locally to an entire function regardless of block scope.\n\n```js\nvar global = true;\nlet blockScoped = true;\n```",
14
+
"tasks": [
15
+
{
16
+
"description":"Run the `varTest` function and look in the console.",
17
+
"tests": [
18
+
"1/01/01"
19
+
],
20
+
"hints": [
21
+
"Click\"SAVE\". ⌘ + S on Mac, ctrl + S on Windows"
22
+
],
23
+
"actions": [
24
+
"open('let.js')",
25
+
"set('// call `varTest()`\nfunction varTest() {\n\tvar x = 1;\n\tif (true) {\n\t\tvar x = 2;\n\t\tconsole.log(x);\n\t}\n\tconsole.log(x);\n}\nvarTest();\n\n')"
26
+
]
27
+
},
28
+
{
29
+
"description":"Change `var` to `let` and run the `letTest` function. Don't forget to look in the console.",
30
+
"tests": [
31
+
"1/01/02"
32
+
],
33
+
"actions": [
34
+
"insert('\n// use `let` and call `letTest()`\nfunction letTest() {\n\tvar x = 3;\n\tif (true) {\n\t\tvar x = 4;\n\t\tconsole.log(x);\n\t}\n\tconsole.log(x);\n}\nletTest();\n\n')"
35
+
]
36
+
},
37
+
{
38
+
"description":"fix the for loop to log numbers from 1 to 5",
39
+
"tests": [
40
+
"1/01/03"
41
+
],
42
+
"actions": [
43
+
"insert('\n// log numbers from 1 to 5\nfor (var i = 1; i <= 5 ; i++ ) {\n setTimeout(function() {\n console.log(i);\n })\n}\n// 6 6 6 6 6\n\n')"
44
+
]
45
+
}
46
+
],
47
+
"onPageComplete":"Great! Now you that you have an idea of how `let` works, continue to look at declaring variables with `const`."
48
+
},
49
+
{
50
+
"title":"Const",
51
+
"description":"Writing basic functions continued.\n\nWe'll write two more basic functions, this time without any help.",
52
+
"tasks": [
53
+
{
54
+
"description":"write a function `divideOne` divides a number by 1",