backgroundColor=['red','green','blue','orange'][Math.floor(Math.random()*4)]
Can someone explain how this code executes in the Javascript syntax, I understand it generates a random number but the result is the color that is in the index value generated in the second square bracket.
In C++ array[][] is used to generate a two-dimensional array but here it is generating the index to be used in the first square bracket pair.
Hope to get clarification on how code execution happens