0

JS, 8/8, 3 question - please somebody explain it to me.

SOS! I don't understand it. People please help.

13th Jan 2017, 7:25 AM
Liliia Lapika-Babych
Liliia Lapika-Babych - avatar
8 Réponses
+ 10
false
2nd Nov 2018, 12:32 PM
Awa Danfa
+ 5
Result for 'var1 && var2' if var1= true and var2 = false? Conditionnals are very much important... You would be adviced to go back and re-learn this part: it's not so hard... and really necessary. However, i'll try to get you basics: - a condition implies a test: if something is true do one thing, else do another... 'something' is the conditional test. ( ie: if a > b ) - you may needed multi-condition testing, so there many way to do it: if condition1 then if condition2... but the nested if can quickly grow too much up, while we can combine condition with conditionals operators: var1 && var2 is read 'var1 and var2", as well as 'condition1 and condition2'. So, the: if ( var1 && var2 ) ... is the same as: if (var1) { if (var2) { /* here you see that the var1 condition must be true for test var2 running, so this block of code is only running if ( var1 is true AND var2 is true ) } } The other wellknown comparison operateur is the OR operator, which is represented by a pipe pair ( || )...
13th Jan 2017, 8:04 AM
visph
visph - avatar
+ 3
What's the result of the expression var1&&var2, if var1=true and var2=false? i don'y understand why false print.
29th Dec 2018, 4:05 PM
Adnan Daniel
Adnan Daniel - avatar
+ 2
False
22nd Dec 2022, 3:47 PM
James Joshua
James Joshua - avatar
0
The thing that puts me on the wrong foot is that both variables and the conditional are written without spaces.
19th Jan 2019, 11:17 AM
Max Aukes
0
False
4th Aug 2020, 2:39 PM
Rama Lakshmi Bolla
Rama Lakshmi Bolla - avatar
0
var1 is true and var2 is true then the result is true because all the expressions are true var1 is true and var2 is false then the result false because not all the expressions are true
5th Nov 2022, 8:08 AM
Dylan Atkins
Dylan Atkins - avatar
0
AND (&&) is a logical operator used when both conditions are true and must be true. So since var2 condition is assigned false in the question, the answer will be FALSE.
5th Feb 2023, 11:17 AM
Chidiebere Chukwudolue
Chidiebere Chukwudolue - avatar