mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-11 13:06:42 +00:00
Update Purity code examples to use interpolation
Also, add in the missing argument to `greet` in the changing-global-state example code.
This commit is contained in:
parent
ff29eb4abd
commit
f55916cac0
1 changed files with 4 additions and 6 deletions
10
readme.md
10
readme.md
|
|
@ -179,7 +179,7 @@ A function is pure if the return value is only determined by its
|
||||||
input values, and does not produce side effects.
|
input values, and does not produce side effects.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const greet = (name) => 'Hi, ' + name
|
const greet = (name) => `Hi, ${name}`
|
||||||
|
|
||||||
greet('Brianne') // 'Hi, Brianne'
|
greet('Brianne') // 'Hi, Brianne'
|
||||||
```
|
```
|
||||||
|
|
@ -189,9 +189,7 @@ As opposed to each of the following:
|
||||||
```js
|
```js
|
||||||
window.name = 'Brianne'
|
window.name = 'Brianne'
|
||||||
|
|
||||||
const greet = () => {
|
const greet = () => `Hi, ${window.name}`
|
||||||
return 'Hi, ' + window.name
|
|
||||||
}
|
|
||||||
|
|
||||||
greet() // "Hi, Brianne"
|
greet() // "Hi, Brianne"
|
||||||
```
|
```
|
||||||
|
|
@ -202,10 +200,10 @@ The above example's output is based on data stored outside of the function...
|
||||||
let greeting
|
let greeting
|
||||||
|
|
||||||
const greet = (name) => {
|
const greet = (name) => {
|
||||||
greeting = 'Hi, ' + name
|
greeting = `Hi, ${name}`
|
||||||
}
|
}
|
||||||
|
|
||||||
greet()
|
greet('Brianne')
|
||||||
greeting // "Hi, Brianne"
|
greeting // "Hi, Brianne"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue