Yes, the ternary operator also exists in Javascript.
The code you posted
for (i=0; i< (x == 0 && y < 0 ? x-y : x+y); i++)
will work, verbatim.
1
solved Is there an equivalent of ? : operator of C# in Javascript/Jquery? [closed]
Yes, the ternary operator also exists in Javascript.
The code you posted
for (i=0; i< (x == 0 && y < 0 ? x-y : x+y); i++)
will work, verbatim.
1
solved Is there an equivalent of ? : operator of C# in Javascript/Jquery? [closed]