-1

If I have:

var key = "Section";
course.key = "101";

I get told course.key is unidentified. I'm trying to set course.Section = "101". Is there anyway to pass key's value in the second line?

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
Qingping
  • 3
  • 3

1 Answers1

0

The property key of course is undefined. Use bracket notation.

course[key] = "101"

is the same as

course["Section"] = "101"

Howzieky
  • 829
  • 7
  • 18