+ 7

How do you run a function inside an if statement?Would you write it like this: if(xTurn){ xMove(); }

13th Mar 2017, 11:17 PM
Andrew Harris
Andrew Harris - avatar
2 Answers
+ 8
It depends on what Xturn is, but yeah. xTurn has to be something that can be expressed as a Boolean value. If true, than the function xMove would be called. Be careful, though. X isn't an object. You are calling xMove();, not x.Move();
14th Mar 2017, 12:27 AM
J.G.
J.G. - avatar
+ 4
xMove has to be true or false if (xTurn == true){ xMove(); }
14th Mar 2017, 1:33 AM
James Cannon
James Cannon - avatar