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
+12-12
Original file line number
Diff line number
Diff line change
@@ -19,35 +19,35 @@ First, we need to practice greeting everyone. (I don't know about you, but I som
19
19
20
20
One might think that we could just type
21
21
22
-
```javascript
22
+
```js
23
23
Hello, everybody!
24
24
```
25
25
26
26
in our browser's console and be done with it. Give it a try. (If you're on a Mac, that would be `Command` + `Option` + `J` together.)
27
27
28
28
You should see something like
29
29
30
-
```shell
30
+
```
31
31
Uncaught ReferenceError: Hello is not defined(…)
32
32
```
33
33
34
34
Well, that won't work. (This is why we practice!) In order to greet our guests, we need to tell JavaScript that we're using a **string**. A string is a collection of characters (letters, numbers, and symbols) wrapped in single or double quotes (or, as we'll see, in back ticks). So to greet everyone, we can write,
35
35
36
-
```javascript
36
+
```js
37
37
'Hello, everybody!'
38
38
```
39
39
40
40
or
41
41
42
-
```javascript
42
+
```js
43
43
"Hello, everybody!"
44
44
```
45
45
46
46
Single or double quotation marks can contain a string variable..
47
47
48
48
What if we want to say hi to a special guest, like Neil deGrasse Tyson? When we wrap strings in single or double quotes, we can join them together using the `+` operator:
49
49
50
-
```javascript
50
+
```js
51
51
var specialGuest ="Neil deGrasse Tyson"
52
52
"Hello, "+ specialGuest +"!"// "Hello, Neil deGrasse Tyson!"
53
53
```
@@ -62,7 +62,7 @@ Alternatively, you can press `ctrl + L` or `command + K`. As long as you don't r
62
62
63
63
When we wrap strings in back ticks, we can use placeholders (`${}`) and insert variables or evaluated JavaScript directly:
64
64
65
-
```javascript
65
+
```js
66
66
var specialGuest ="Neil deGrasse Tyson";
67
67
68
68
`Hello, ${specialGuest}! High ${3+2}!`// "Hello, Neil deGrasse Tyson! High 5!"
@@ -82,7 +82,7 @@ All three tests have failed! This is okay, and it's expected — you haven't wri
82
82
83
83
In `index.js`, you'll see five lines of code:
84
84
85
-
```javascript
85
+
```js
86
86
var greeting ="";
87
87
88
88
var specialGuest ="Neil deGrasse Tyson"
@@ -98,11 +98,11 @@ Each line has a test associated with it. When the tests fail, they show us what
98
98
99
99
When you first run `learn`, you should see something like this:
Let's walk through that first error together. First, we see the test title:
104
104
105
-
```bash
105
+
```bash
106
106
1) strings defines `greeting`:
107
107
```
108
108
@@ -112,7 +112,7 @@ we're handling strings.
112
112
113
113
Continuing on with the test output, we can now make better sense of the next few lines:
114
114
115
-
```bash
115
+
```bash
116
116
AssertionError: '!' == 'Hello, everybody!'
117
117
+ expected - actual
118
118
@@ -134,13 +134,13 @@ Next, the title tells us that `index.js` "defines `greeting`." Let's look in `in
134
134
135
135
What if, instead of assigning `""` to `greeting`, we assign `"Hello, everybody!"`, like the test expects. Go ahead and change that line in `index.js` so it reads
136
136
137
-
```javascript
137
+
```js
138
138
var greeting ="Hello, everybody!";
139
139
```
140
140
141
141
save the file, and rerun your tests. You should see
142
142
143
-

143
+

0 commit comments