Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if a is equal to b.
Javascript
if (a [1] b) { console.log("Equal"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' instead of '===' causes unexpected results.
Using '!=' instead of '==='.
✗ Incorrect
The '===' operator checks if two values are equal and of the same type.
2fill in blank
mediumComplete the code to check if x is greater than 10.
Javascript
if (x [1] 10) { console.log("x is greater than 10"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' causes wrong condition.
Using '===' compares equality, not greater than.
✗ Incorrect
The '>' operator checks if the left value is greater than the right value.
3fill in blank
hardFix the error in the comparison to check if num is not equal to 5.
Javascript
if (num [1] 5) { console.log("Not equal to 5"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '!=='.
Using '==' which checks equality, not inequality.
✗ Incorrect
The '!==' operator checks if two values are not equal or not the same type.
4fill in blank
hardFill both blanks to check if age is between 18 and 30 (inclusive).
Javascript
if (age [1] 18 && age [2] 30) { console.log("Age is between 18 and 30"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '>=' excludes 18.
Using '<' instead of '<=' excludes 30.
✗ Incorrect
Use '>=' to check age is at least 18 and '<=' to check age is at most 30.
5fill in blank
hardFill all three blanks to create an object with keys as uppercase names and values as ages greater than 20.
Javascript
const result = people.reduce((acc, person) => {
if (person.age [3] 20) {
acc[[1]] = [2];
}
return acc;
}, {}); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for age condition.
Using 'person.name' instead of uppercase.
Using wrong value for object property.
✗ Incorrect
Use 'person.name.toUpperCase()' as key, 'person.age' as value, and '>' to check age greater than 20.