Skip to content

Commit 50f888f

Browse files
Update explanation of 'important' property evaluation
The original text claimed that the expression body.important || false “converts its value to a boolean,” which is misleading. The updated version clarifies that the expression returns the original truthy value if it exists or false if the property is missing or falsy. It also links to the same external resources for [truthy] and [falsy] that were introduced earlier in the course to maintain consistency and accuracy.
1 parent 9d702f0 commit 50f888f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/3/en/part3a.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@ If the <i>important</i> property is missing, we will default the value to <i>fal
708708
important: body.important || false,
709709
```
710710

711-
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.
711+
If the data saved in the _body_ variable has the <i>important</i> property and its value is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), the expression will evaluate to that value. If the property does not exist, its value will be <i>undefined</i>, which is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy), and the expression will therefore evaluate to false, which is defined on the right-hand side of the vertical lines.
712712

713-
> 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...
713+
> 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. If the property has any truthy value, that value itself will be returned.
714714
715715
You can find the code for our current application in its entirety in the <i>part3-1</i> branch of [this GitHub repository](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part3-1).
716716

0 commit comments

Comments
 (0)