You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
982 B

## Seeker of Truth
### Truthy and Falsy
In JS, all values are either **truthy** or **falsy**, this means if used in a condition, truthy values will validate the condition while falsy values would not.
Here is the list of falsy values:
- `undefined` and `null`
- the numbers `0` and `NaN`
- the empty string `''`
- and the boolean `false` of course
All other values are truthy, note that empty arrays and empty objects are truthy, but the empty string is not.
```js
if ('') {
console.log('Since empty string are falsy, this will never log')
}
if ('hello') {
console.log('this will always log as the string is not empty')
}
```
### Operator `!`
The `!` (NOT operator) can be used to convert a truthy value to `false` or a falsy value to `true`.
example:
```js
let money = 0
let noMoney = !money
console.log(noMoney) // true
```
In this case, 0 is falsy, so the `!` return the value `true`
### Instructions
R
```js
let truth = 0
if (!truth) {
console.log()
}
```