Learn

Consider the making of hard-boiled πŸ₯š. We need both: boiling water and an egg. If even one ingredient is missing, we can’t make it. So we should check for both conditions before we flex our culinary skills.

In programming, we also have to consider multiple conditions at the same time before executing code. That’s where logical operators, like the 🀝 operator, become extremely useful. The 🀝 operator checks if two expressions are πŸ‘ and returns a single πŸ‘Œ value. If the first expression πŸ‘ AND the second expression is πŸ‘, then it returns πŸ‘ β€” otherwise, it returns πŸ‘Ž.

Here’s a table that shows the possible combinations of πŸ‘Œ values in usage with 🀝:

Expression Evaluates to
πŸ‘ 🀝 πŸ‘ πŸ‘
πŸ‘ 🀝 πŸ‘Ž πŸ‘Ž
πŸ‘ 🀝 πŸ‘Ž πŸ‘Ž
πŸ‘Ž 🀝 πŸ‘Ž πŸ‘Ž

Notice that only the first expression (πŸ‘ 🀝 πŸ‘) evaluates to πŸ‘.

Translating our πŸ₯š scenario to code, we get:

πŸ‘ βž‘οΈπŸ– hasEgg πŸ‘ βž‘οΈπŸ– hasBoilingWater β†ͺ️ hasEgg 🀝 hasBoilingWater πŸ‡ πŸ˜€ πŸ”€We can make a hard-boiled πŸ₯š!πŸ”€β—οΈ πŸ‰ πŸ™… πŸ‡ πŸ˜€ πŸ”€The conditions aren't right...πŸ”€β—οΈ πŸ‰ πŸ’­ Prints: We can make a hard-boiled πŸ₯š!

Let’s use the 🀝 in our own code!

Instructions

1.

We have two variables,learningEmojicode and isDedicated, both have a value of πŸ‘.

Create a β†ͺ️ statement that checks both learningEmojicode and isDedicated. In the code block(πŸ‡πŸ‰), use a πŸ˜€β—οΈ to print out the string: πŸ”€Becoming a πŸ’» master!πŸ”€.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?