0
0
Javascriptprogramming~10 mins

Operator precedence in Javascript - Interactive Code Practice

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

Complete the code to correctly add 2 and 3, then multiply by 4.

Javascript
let result = (2 + 3) [1] 4;
console.log(result);
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * causes the result to be 5 + 4 = 9, which is incorrect.
Using - or / changes the meaning and result unexpectedly.
2fill in blank
medium

Complete the code to get the correct result of 2 + 3 * 4 without parentheses.

Javascript
let result = 2 + 3 [1] 4;
console.log(result);
Drag options to blanks, or click blank then click option'
A+
B/
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * causes the operations to be done left to right, which is not correct here.
Using - or / changes the calculation and result.
3fill in blank
hard

Fix the error in the expression to get the correct result of 10 minus 2 times 3.

Javascript
let result = 10 [1] 2 * 3;
console.log(result);
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of - changes the result to 16.
Using * or / here changes the meaning and causes wrong results.
4fill in blank
hard

Fill both blanks to create an expression that divides 20 by 5 and then adds 3.

Javascript
let result = 20 [1] 5 [2] 3;
console.log(result);
Drag options to blanks, or click blank then click option'
A/
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the operators changes the result.
Using subtraction or multiplication instead of addition changes the meaning.
5fill in blank
hard

Fill all three blanks to create an expression that multiplies 4 by 3, subtracts 2, then adds 5.

Javascript
let result = 4 [1] 3 [2] 2 [3] 5;
console.log(result);
Drag options to blanks, or click blank then click option'
A*
B-
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Changing the order of operators changes the result.
Using division instead of multiplication changes the meaning.