As we previously mentioned, we do things based on our present conditions. Like, if we’re hungry, we’d get something to eat; if it’s raining, we would carry an umbrella.
How our actions follow the same:
- If there’s some condition
- Take some action
Using Emojicode, we can add this decision making ability into our program using the
↪️ statement. This
↪️ checks a condition and if the condition evaluates to
👍, it runs a block of code.
Take for instance:
↪️ 👍 🍇 😀 🔤The condition is 👍🔤❗️ 🍉 💭 Prints: The condition is 👍
Notice how we added the
👍 after the
↪️. Then we follow up with a block of code using
🍉. Inside the block of code, we added
😀❗️ to print out the string
🔤The condition is 👍🔤.
If we change the condition from
👎 like so:
↪️ 👎 🍇 😀 🔤The condition is 👍🔤❗️ 🍉 💭 Nothing prints
Our code block doesn’t run since our condition is
👎. Therefore, we wouldn’t get anything printed to the terminal.
Let’s create our own conditional to see it in action.
↪️ statement that accepts the condition
👍. Then, add an empty code block using
Inside the code block, add a print statement using
😀❗️ and print out a string of your choice! For example:
🔤I'm 👑 of the world!🔤.
Now just play around with the code:
- Try changing the
- Add in more
- Create additional conditionals.