×
Write down what the following statements will return. Try to figure this out before putting the commands in the chrome console.
2 == "2";2 === 2;10 % 3;10 % 3 === 1;true && false;false || true;true || false;Answer the following questions about this code block:
let isLearning = true; if(isLearning){ console.log("Keep it up!"); } else { console.log("Pretty sure you are learning...."); }
What should the above code console.log?
Why do we not need to specify if(isLearning === true)? Why does if(isLearning) work on its own?
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"); }
firstvariable when it is initialized?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".
What is a falsey value? List all the falsey values in JavaScript.
You can find the code here
When you're ready, move on to Array Basics