+ 16
if condition in if() statement evaluates to true then only if() block executes.
if(true){
//statement(s) in this block will execute
}
if(false){
//statement(s) in this block will NOT execute
}
+ 13
!true means false, !(NOT) operator changes true to false & false to true.
thatswhy else block get executed & value of x becomes 2
+ 3
You are not checking if x is false, you are using an if-statement that is always false.
If you want to check if x is false, you should use if(x == false) or simply if(!x).
In both examples, x would be false and the else block would be executed, making x receive 2 as its new value.
+ 3
your answer
https://code.sololearn.com/W6M0cwApNGJI/?ref=app
+ 1
đ



