Task 2: Using the logical || operator
- satyanarayan behera
- Aug 25, 2022
- 1 min read
Imagine you are coding a video game. Currently, you’re about to code some snippets related to the game over condition.
You need to code a new variable named timeRemaining and set it to 0. You also need to code a new variable named energy and set it to 10.
Next, you should write a piece of code that could be used to determine if the game is over, based on whether either the value of the timeRemaining variable is 0 or the value of the energy variable is 0.
Complete the task using the following steps:
Declare the variable timeRemaining, and assign the value of 0 to it.
Declare the variable energy, and assign the value of 10 to it.
Console log the following parameters: "Game over: ", and timeRemaining == 0 || energy == 0
Note that the expected output in the console should be: "Game over: true".
var timeRemaining =0;
var energy =10;
console.log("Game over:", timeRemaining==0 || energy==0);
Comments