Skip to content

Commit f55916c

Browse files
Update Purity code examples to use interpolation
Also, add in the missing argument to `greet` in the changing-global-state example code.
1 parent ff29eb4 commit f55916c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

readme.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ A function is pure if the return value is only determined by its
179179
input values, and does not produce side effects.
180180

181181
```js
182-
const greet = (name) => 'Hi, ' + name
182+
const greet = (name) => `Hi, ${name}`
183183

184184
greet('Brianne') // 'Hi, Brianne'
185185
```
@@ -189,9 +189,7 @@ As opposed to each of the following:
189189
```js
190190
window.name = 'Brianne'
191191

192-
const greet = () => {
193-
return 'Hi, ' + window.name
194-
}
192+
const greet = () => `Hi, ${window.name}`
195193

196194
greet() // "Hi, Brianne"
197195
```
@@ -202,10 +200,10 @@ The above example's output is based on data stored outside of the function...
202200
let greeting
203201

204202
const greet = (name) => {
205-
greeting = 'Hi, ' + name
203+
greeting = `Hi, ${name}`
206204
}
207205

208-
greet()
206+
greet('Brianne')
209207
greeting // "Hi, Brianne"
210208
```
211209

0 commit comments

Comments
 (0)