The OR operator,or a mystery to me


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/2/1?curriculum_id=506324b3a7dffd00020bf661

i passed the exercise, but i really dont get why the OR operator works like this :
else if(!(iLoveJavaScript || iLoveLearning))
why is this an OR operator when the code wants to check if both variables are false ?



#2

These two lines are like a substitute for writing or. For example when you want to account for two different outcomes in an if statement.


#3

Thanks for your answer
what i meant is that in my head this is an AND situation while there is an OR here, like this:

if(illovejavascript AND ilovelearning are False)...
but here, instead of the AND there is an OR
so why isnt it written if(iLoveJavaScript && iLoveLearning)
see what i mean ? i get what or means, just not why it's here in a situation when they both need to be false, and not just one of them, so this is only aimed at one outcome : both falses (if i get this exercise right of course :slight_smile: )


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.