Skip to content

Commit c6be048

Browse files
authored
Merge pull request #4237 from Bolu-Adekanmbi/patch-1
Part 3a: Update explanation of 'important' property evaluation
2 parents c8e92a6 + 50f888f commit c6be048

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)