0

Please help me. How is the 4th line works?

var x, y, z; x = 10%6 != 106; y = 5; z=(x||y >6)?y + 4:x-4; x = 2 * y + z; document.write(x);

1st Nov 2022, 6:38 PM
Kenken Santos
Kenken Santos - avatar
1 Resposta
+ 2
x = 10%6 != 106 => x = true is a boolean data type so it has true value and in z = (x || y>6)? y+4:x-4 x is a conditional return which has the value true so the condition as a whole becomes true as or operator is being used therefore z = y+4 = 5+4 = 9 then, x = 2*y + z = 10 + 9 = 9 Hence the output is 19
1st Nov 2022, 6:55 PM
Just Some Random Guy
Just Some Random Guy - avatar