javascript - How to unshorten this js code -
this question has answer here:
i trying understand code of this tic-tac-toe (30 lines of code) game , encountered strange me notation of js.
t[id] ? ai() : move(id, 'ai');!checkend() ? (role == 'player') ? ai() : null : reset()
i know shortened version of if-statement, don't know how convert it.
thanks in advance.
this ternary operator in javascript.
t[id] ? ai() : move(id, 'ai'); translates to:
if (t[id]) ai(); else move(id, 'ai'); and !checkend() ? (role == 'player') ? ai() : null : reset() to:
if (!checkend()) if (role == 'player') ai(); else ; else reset();
Comments
Post a Comment