You are coding an RPG game, where each character has certain skills based on the value saved in their score.
- Create a variable named score and set it to 8
- Use console.log() that includes the string "Mid-level skills:" and compares the score variable to 0 and below 10 using the && operator
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".
You need to code a small program that takes a number and determines if it's an even number (like 2, 4, 6, 8, 10).
To achieve this task, you need to declare six variables, as follows:
-
The first variable, named num1, should be assigned a number value of 2.
-
The second variable, named num2, should be assigned a number value of 5.
-
The third variable, named test1, should be assigned the calculation of num1 % 2. Note: executing this code will return a number.
-
The fourth variable, named test2, should be assigned the calculation of num2 % 2. Note: executing this code will also return a number.
-
The fifth variable, named result1, should be assigned the result of comparing if the number stored in the test1 variable is not equal to 0, in other words, this: test1 == 0.
-
The sixth variable, named result2, should be assigned the result of comparing if the number stored in the test2 variable is not equal to 0, in other words, test2 == 0.
Run console log two times after you've set the variables:
-
The first console log should have the following code between parentheses: "Is", num1, "an even number?", result1
-
The second console log should have the following code between parentheses: "Is", num2, "an even number?", result2
Note: The output to the console should be as follows:
Is 2 an even number? true
Is 5 an even number? false
Console log the result of adding two numbers, 5 and 10, using the + operator.
Note: This task should be completed on a single line of code. The output in the console should be 15.
Code three variables:
-
The first variable should be a string with the following value: "Now in ". Name the variable now.
-
The second variable should be a number with the value: 3. Name the variable three.
-
The third variable should a string with the following value: "D!". Name the variable d.
-
Console log the following code: now + three + d.
Note: The expected output should be: "Now in 3D!".
Code a new variable and name it counter, assigning it to the value of 0.
On the next line, use the += operator to increase the value of counter by 5.
On the next line, use the += operator to increase the value of counter by 3.
On the fourth line, console log the value of the counter variable.
Note: The output value should be 8.