Can you explain a bit further what the code you posted does?
https://developer.mozilla.org/en-US/docs/Web/API/Element/cla...
Property Accessors (Bracket Notation):
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Conditional (ternary) Operator:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...