Another helpful logical operator is the πŸ‘ operator.

The πŸ‘ operator also checks two expressions and returns a πŸ‘Œ value. The major difference is that the πŸ‘ operator returns πŸ‘ so long as a single expression is πŸ‘.

Here’s the table of expression combinations:

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

From the table above, we see that the only expression that returns πŸ‘Ž is when both values are πŸ‘Ž, (πŸ‘Ž πŸ‘ πŸ‘Ž).

Let’s look over a code snippet using πŸ‘:

πŸ‘ βž‘οΈπŸ– hasUmbrella πŸ‘Ž βž‘οΈπŸ– hasRaincoat β†ͺ️ hasUmbrella πŸ‘ hasRaincoat πŸ‡ πŸ˜€ πŸ”€Walking in the rain is fun!πŸ”€β—οΈ πŸ‰ πŸ™… πŸ‡ πŸ˜€ πŸ”€Let's stay insideπŸ”€β—οΈ πŸ‰ πŸ’­ Prints: Walking in the rain is fun!

Notice, hasUmbrella has a value of πŸ‘, while hasRaincoat has a value of πŸ‘Ž. Our condition checks hasUmbrella πŸ‘ hasRaincoat. As long as either hasUmbrella OR hasRaincoat is πŸ‘, it returns πŸ‘. Since Walking in the rain is fun! was printed, we can confirm that our condition returned πŸ‘.



Under the πŸ˜€ πŸ”€Heads I win, Tails you loseπŸ”€β—οΈ statement, create a β†ͺ️ statement that checks isHeads or isTails. Then, add its πŸ‡πŸ‰ block that contains a πŸ˜€β—οΈ with the string: πŸ”€Looks like I winπŸ”€.

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?