Learn
In Emojicode, operator assignment provides a short-hand method for modifying the value of variables.
Different compound assignment operators include:
⬅️➕
: addition assignment⬅️➖
: subtraction assignment⬅️✖️
: multiplication assignment⬅️➗
: division assignment⬅️🚮
: modulo assignment
For example:
0 ➡️ 🖍🆕i 💭 i is 0 i ⬅️➕ 1 💭 i is now 1 i ⬅️➕ 5 💭 i is now 6 i ⬅️➗ 3 💭 i is now 2
The variable i
is first incremented by one, then by 5, and finally divided by 3.
Instructions
1.
In the code editor, we have already declared and initialized a variable called level
.
Use addition assignment to increment level
by 2.
2.
Use subtraction assignment to decrement level
by 1.
3.
Print the result of level
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.