Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the number is positive.
Javascript
if (number [1] 0) { console.log('Positive number'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' will check for negative numbers instead.
Using '===' checks for equality, not greater than.
✗ Incorrect
The '>' operator checks if the number is greater than zero, meaning it is positive.
2fill in blank
mediumComplete the code to print 'Even' if the number is divisible by 2.
Javascript
if (number [1] 2 === 0) { console.log('Even'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' will not check divisibility.
Using '*' multiplies numbers, not checks remainder.
✗ Incorrect
The '%' operator gives the remainder. If remainder is 0 when divided by 2, number is even.
3fill in blank
hardFix the error in the if statement to check if age is at least 18.
Javascript
if (age [1] 18) { console.log('Adult'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' checks for younger than 18.
Using '==' checks only exactly 18, not older.
✗ Incorrect
The '>=' operator checks if age is greater than or equal to 18, meaning adult or older.
4fill in blank
hardFill both blanks to print 'Teenager' if age is between 13 and 19 inclusive.
Javascript
if (age [1] 13 && age [2] 19) { console.log('Teenager'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for the first blank would exclude 13.
Using '>' for the second blank would exclude 19.
✗ Incorrect
Use '>=' to check age is at least 13 and '<=' to check age is at most 19.
5fill in blank
hardFill the blanks to print 'Grade A' if score is above 90, 'Grade B' if score is above 80, else 'Grade C'.
Javascript
if (score [1] 90) { console.log('Grade A'); } else if (score [2] 80) { console.log('Grade B'); } else { console.log('Grade C'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' would include boundary scores incorrectly.
Using '<=' in the blanks would cause wrong grade assignments.
✗ Incorrect
Use '>' to check if score is strictly greater than 90 for A and greater than 80 for B.