Advanced JSX 11/16. Why the straight brackets?

Advanced JSX 11/16

This does not work

var img = <img src={pics.{coinToss() == 'heads' ? 'kitty' : 'doggy'}} />;

While this does.

var img = <img src={pics[coinToss() == 'heads' ? 'kitty' : 'doggy']} />;

I don't understand why this is. What's the significance of the [and ]?
I added the . in the first code because I thought the text that needed to be passed to the img src needed to be


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.