if xy if x10 y If x y if x10 y and 10x 100 alertone Pr
if (x>=y) {
if (x*10 <100) {
alert(\'one);
}
else{ alert(\'two\');
}
}
else { alert(\'three\')\' }
x=0 y=5
x=0 y=-5
x=9 y=9
x=22 y=21
how do you predict this behavior
Solution
Here is the code traced for you:
if (x>=y)           //If x >= y
 {
 if (x*10 <100)   //If x >= y, and 10x < 100
 {
 alert(\'one);   //Print one.
 }
 else               //If x >= y, and 10x >= 100
 {
 alert(\'two\');   //Print two.
 }
 }
 else               //If x < y
 {
 alert(\'three\')    //Print \'three\'
 }
 
 x=0       y=5    x < 5, so, three will be printed.
 x=0       y=-5   x >= y, and 10x < 100, so, one will be printed.
 x=9       y=9       x >= y, and 10x < 100, so, one will be printed.
 x=22   y=21   x >= y, and 10x >= 100, so, two will be printed.

