Learn
Variables
Operator Assignment
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
.