Grouping Expressions

In Math class, we might have been asked to solve equations like:

2 * 6 + 10 / 2

If we read out our equation from left to right we might think that the answer is 11. However, it’s actually 17 because we have to follow a specific order of operations. In the United States, there’s a helpful mnemonic called PEMDAS that helps us remember to the order:

  1. 2 * 6, which is 12
  2. Then we have to divide! So 10 / 2 is 5.
  3. Lastly, we add 12 and 5 to get 17!

But wouldn’t it be nice if someone put in parentheses to group together expressions for us to evaluate? That way we don’t have to remember the specific ordering. Our neatly grouped expression would be:

(2 * 6) + (10 / 2)

The insertion of parentheses makes it clear which operations are done first. Emojicode also has its own order of operations that determines the order in which expressions are evaluated. But, we can control the order using the emoji equivalent of parentheses, ( ), 🀜 πŸ€›. When we translate our math equation to Emojicode, we get:

🀜 2 βœ–οΈ 6 πŸ€› βž• 🀜 10 βž— 2 πŸ€›

Using 🀜 πŸ€›, we make it clearer for which expressions go together and we decide the order of expressions.



Let’s use 🀜 πŸ€› to make our first conditional easier to read.

Currently, we have the conditional:

β†ͺ️ offer ▢️ minPrice 🀝 offer ◀️ maxPrice πŸ‡ πŸ˜€ πŸ”€Offer accepted!πŸ”€β—οΈ πŸ‰

In the condition, add a set of 🀜 πŸ€› around offer ▢️ minPrice and another set of 🀜 πŸ€› around offer ◀️ maxPrice. This way we have a clear grouping of expressions.


In the second conditional, the condition looks like:

πŸ‘ πŸ‘ πŸ‘ 🀝 πŸ‘Ž

As is, the condition evaluates to πŸ‘. We need to group together an expression inside the condition, using a single set of 🀜 πŸ€›, to make the condition evaluate to πŸ‘Ž.


The last expression is stored in a variable mathPuzzle that reads as:

10 βœ–οΈ 6 βž– 2 βž— 2

It currently evaluates to 59, but we want it to evaluate to 20 instead. Add a single set of 🀜 πŸ€› to make this happen.

Folder Icon

Take this course for free

Already have an account?