0
0
Javascriptprogramming~10 mins

Why operators are needed in Javascript - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A*
B-
C/
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction - instead of addition +.
2fill in blank
medium

Complete 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'
A<
B>
C===
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than < instead of greater than >.
3fill in blank
hard

Fix 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'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition + or subtraction - instead of multiplication *.
4fill in blank
hard

Fill 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'
A'A'
B'b'
C'B'
D'a'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase letters when uppercase is required.
Not using quotes around keys.
5fill in blank
hard

Fill 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'
A>=
B<=
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using > or < without equals, missing boundary values.