Voltra Neo Voltra Neo - 2 months ago 4
Javascript Question

JSLint error from ternary statement

I'd like to know why ternary conditional-statements like these:

on_actu.boolean ? IMG1 = "on-actu.png" : IMG1 = "off-actu.png";

give me the following JSLint error :

expected an assignment or function call and instead saw an expression


You're using the ternary operator wrong.

ValueToAssign = BooleanConditional ? valueOne : valueTwo;

More information here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator