+ 1

can anyone explain me clearly what the logical operators (and,or,not) are plz? im stuck...

17th Aug 2017, 9:53 PM
Zach
14 Answers
+ 6
https://code.sololearn.com/Wj6VyBq8POTl/?ref=app Please check that code and try to follow each condition
17th Aug 2017, 10:43 PM
Daniel
Daniel - avatar
+ 5
AND is to check TRUE two conditions Example: if (a>10 and a<15) if both conditions are TRUE then result is TRUE and in that example 'a' is a number between 11 and 14 but if some or both are FALSE then result is FALSE
17th Aug 2017, 10:02 PM
Daniel
Daniel - avatar
+ 5
NOT is to check "negative" condition. Example: If (not (a>10)) If a=5 then not(5>10)=not(false)=TRUE If a=11 then not(11>10)=not(true)=FALSE
17th Aug 2017, 10:17 PM
Daniel
Daniel - avatar
+ 4
OR is to check TRUE one or both conditions. Example: if (a>10 or a<15) if both conditions are TRUE then result is TRUE, if a>10 and not a<15 then result is TRUE and 'a' could be a number from 15 to infinite, if not a>10 and yes a<15 then result is TRUE and 'a' could be a number from 10 to minus infinite. Of course if both conditions are FALSE then result is FALSE
17th Aug 2017, 10:10 PM
Daniel
Daniel - avatar
+ 2
Can you explain in a more simple way... I dont get it and its bothering me really bad
17th Aug 2017, 10:20 PM
Zach
+ 2
I wanna code it tho how do i put it? I tried the same way as the AND operator an doesnt work
17th Aug 2017, 10:32 PM
Zach
+ 2
Ok thanks a lot
17th Aug 2017, 10:36 PM
Zach
+ 1
Ok and what about the "NOT" one? It says "if the operand is false,and false,if the operand is true" what does that mean?
17th Aug 2017, 10:04 PM
Zach
+ 1
example for NOT: x= 3, y=5; if( x!== y) // 3 not 5 = true { /* do something*/ } (x !== y) is same as (3 NOT 5) and its True because 3 not equal 5
17th Aug 2017, 10:22 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
Oh i see...
17th Aug 2017, 10:31 PM
Zach
+ 1
in js use : "&&" as "AND" operator, "||" as "OR" operator, "!" as "NOT" operator
17th Aug 2017, 10:35 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
in the future, if u have some problems - show us your code to understand where's your mistake
17th Aug 2017, 10:38 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 1
Ok thank u so much guys
17th Aug 2017, 10:46 PM
Zach
+ 1
Oh i see why now... I didnt do the if and else yet
17th Aug 2017, 10:48 PM
Zach