if/else examples
Wed Jun 22 2022 20:37:39 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
// Declare and initialize the variables for exercise 1 here:
let engineIndicatorLight = "red blinking";
let spaceSuitsOn = true;
let shuttleCabinReady = true;
let crewStatus = spaceSuitsOn && shuttleCabinReady;
let computerStatusCode = 200;
let shuttleSpeed = 15000
// BEFORE running the code, predict what will be printed to the console by the following statements:
if (engineIndicatorLight === "green") {
console.log("engines have started");
} else if (engineIndicatorLight === "green blinking") {
console.log("engines are preparing to start");
} else {
console.log("engines are off");
}
let tool = 'marker';
// Use short circuit evaluation to assign writingUtensil variable below:
let writingUtensil = tool || "pen";
console.log(`The ${writingUtensil} is mightier than the sword.`);
let stopLight = 'yellow';
if (stopLight === 'red') {
console.log('Stop!');
} else if (stopLight === 'yellow') {
console.log('Slow down.');
} else if (stopLight === 'green') {
console.log('Go!');
} else {
console.log('Caution, unknown!');
}
content_copyCOPY
Comments