0

I solved the one freeCodeCamp challenge which asked you to turn a Switch/Case statement into an object and access the properties through variables, the solution was result = lookup[val].

I initially got it wrong doing result = lookup.val.

I know it has something to do with the brackets, interpreting as a strings, and that you use dot notation when you know the properties whereas brackets when you don't, but I don't have a good grasp on it conceptually.

I got the answer just swinging in the dark and trying other stuff but can someone explain why it's a bracket vs dot?

  • Does this answer your question? [JavaScript property access: dot notation vs. brackets?](https://stackoverflow.com/questions/4968406/javascript-property-access-dot-notation-vs-brackets) – SuperStormer Jun 30 '22 at 19:45
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jun 30 '22 at 23:26

0 Answers0