[Solved] What does the colon “:” and the question mark “?” operators do? [duplicate]


This is a ternary operator the way it works is :

   condition ? (things to do if true) : (things to do if false);

In your code what it does is :

if value of  Math.random() - 0.5 < 0 
   then assign change a values of -5 
else 
    assign change a value of 5.

1

solved What does the colon “:” and the question mark “?” operators do? [duplicate]