Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add 5 to the variable num using an assignment operator.
Javascript
let num = 10; num [1] 5;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+=' will subtract instead of add.
Using '*' or '/' will multiply or divide instead of adding.
✗ Incorrect
The '+=' operator adds the value on the right to the variable on the left and assigns the result back to the variable.
2fill in blank
mediumComplete the code to multiply count by 3 using an assignment operator.
Javascript
let count = 4; count [1] 3;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of multiply.
Using '-=' or '/=' will subtract or divide instead of multiply.
✗ Incorrect
The '*=' operator multiplies the variable by the value on the right and assigns the result back to the variable.
3fill in blank
hardFix the error in the code to subtract 2 from score using an assignment operator.
Javascript
let score = 15; score [1] 2;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of subtract.
Using '*=' or '/=' will multiply or divide instead of subtract.
✗ Incorrect
The '-=' operator subtracts the value on the right from the variable and assigns the result back to the variable.
4fill in blank
hardFill both blanks to divide total by 4 and assign the result back to total.
Javascript
let total = 20; total [1] [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' instead of '/=' will add instead of divide.
Using 2 instead of 4 will divide by the wrong number.
✗ Incorrect
The '/=' operator divides the variable by the value on the right and assigns the result back. We divide by 4 here.
5fill in blank
hardFill all three blanks to increase value by 10, then multiply by 2, and finally subtract 5 using assignment operators.
Javascript
let value = 5; value [1] 10; value [2] 2; value [3] 5;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the order of operators.
Using '/=' instead of '*=' or '-='.
✗ Incorrect
First, '+=' adds 10 to value. Then '*=' multiplies value by 2. Finally, '-=' subtracts 5 from value.