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.

Folder Icon

Take this course for free

Already have an account?