Skip to content

Commit 5b88bd5

Browse files
authored
Merge pull request #3324 from chengd42/patch-1
Update part3a.md: add boolean conversion to body.important
2 parents fa62630 + 2d5f27a commit 5b88bd5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/3/en/part3a.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ app.post('/api/notes', (request, response) => {
762762

763763
const note = {
764764
content: body.content,
765-
important: body.important || false,
765+
important: Boolean(body.important) || false,
766766
id: generateId(),
767767
}
768768

@@ -790,10 +790,10 @@ If the content property has a value, the note will be based on the received data
790790
If the <i>important</i> property is missing, we will default the value to <i>false</i>. The default value is currently generated in a rather odd-looking way:
791791

792792
```js
793-
important: body.important || false,
793+
important: Boolean(body.important) || false,
794794
```
795795

796-
If the data saved in the _body_ variable has the <i>important</i> property, the expression will evaluate to its value. If the property does not exist, then the expression will evaluate to false which is defined on the right-hand side of the vertical lines.
796+
If the data saved in the _body_ variable has the <i>important</i> property, the expression will evaluate its value and convert it to a boolean value. If the property does not exist, then the expression will evaluate to false which is defined on the right-hand side of the vertical lines.
797797

798798
> To be exact, when the <i>important</i> property is <i>false</i>, then the <em>body.important || false</em> expression will in fact return the <i>false</i> from the right-hand side...
799799

0 commit comments

Comments
 (0)