I am referencing this post:
are there dictionaries in javascript like python?
My dictionary looks like this:
states_dictionary = {
"1":["60","purple","1t"],
"2":["50","blue","2t"],
"3":["40", "red","3t"],
"4":["30","yellow","4t"],
"5":["20","black","5t"],
"6":["10", "green","6t"],
"7":["10", "orange","7t"]
};
I am have a variable called reading
that on first iteration, is "1". I want to get the color corresponding to this variable using a dictionary.
I use:
color = states_dictionary.reading[1]
However, I get an error Uncaught TypeError: Cannot read property '1' of undefined
Why is this?