Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add two numbers and store the result in sum.
Javascript
let a = 5; let b = 3; let sum = a [1] b;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction
- instead of addition +.✗ Incorrect
The + operator adds two numbers together.
2fill in blank
mediumComplete the code to check if age is greater than 18.
Javascript
let age = 20; if (age [1] 18) { console.log('Adult'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than
< instead of greater than >.✗ Incorrect
The > operator checks if the left value is greater than the right value.
3fill in blank
hardFix the error in the code to multiply x and y.
Javascript
let x = 4; let y = 7; let product = x [1] y;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition
+ or subtraction - instead of multiplication *.✗ Incorrect
The * operator multiplies two numbers.
4fill in blank
hardFill both blanks to create an object with keys as uppercase letters and values as numbers greater than 10.
Javascript
const data = {
[1]: 15,
[2]: 20
}; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase letters when uppercase is required.
Not using quotes around keys.
✗ Incorrect
Keys in objects are strings. Using uppercase letters 'A' and 'B' as keys matches the requirement.
5fill in blank
hardFill both blanks to create a condition that checks if score is between 50 and 100 (inclusive).
Javascript
if (score [1] 50 && score [2] 100) { console.log('Pass'); } else { console.log('Fail'); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
> or < without equals, missing boundary values.✗ Incorrect
The condition uses >= to check if score is at least 50 and <= to check if score is at most 100.