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.
 
 
 
 
 
 
Clement Denis 3cdfd1a34c discovery-piscine: update exercises and test 4 years ago
..
README.md discovery-piscine: update exercises and test 4 years ago

README.md

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.

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:

let money = 0
let noMoney = !money

console.log(noMoney) // true

In this case, 0 is falsy, so the ! return the value true

Instructions

Seek the truth and claim your verdict !

  • Log 'The truth was spoken.' if the value of the provided variable truth is truthy
  • Log 'Lies !!!!' if the value of the provided variable truth is falsy