True
True
1
True
False
True
True
(a)
let isLearning = true; if(isLearning){ console.log("Keep it up!"); } else { console.log("Pretty sure you are learning...."); }
It will console.log "Keep it up" because the value of isLearning is truthy.
Because true is a truthy value
(b)
let firstvariable; let secondvariable = ""; let thirdvariable = 1; let secretMessage = "Shh!";
if(firstvariable){ console.log("first"); } else if(firstvariable || secondvariable){ console.log("second"); } else if(firstvariable || thirdvariable){ console.log("third"); } else { console.log("fourth"); }
It will console.log "third" since the third variable is true and the first variable and the second variable are false.this is because the || (or) operator returns true if either condition is true.
It is undefined because it is not assigned to any value.
The value of first variable is a falsey value because undefined is a falsey value.
It is a not a truthy value since it is an empty string and empty strings are said to be falsey values.
The third variable is a truthy value since it is a number.All numbers are said to be truthy except for 0 which is a falsey value.
1.Research Math.random here and write an if statement that console.log’s “Over 0.5” if Math.random returns a number greater than 0.5. Otherwise console.log “Under 0.5”.
Answered in index.js file
They are values that are actually false when they are used in javaScript. Examples of falsey values are;undefined,null,Nan,0,false and an empty string ("").