Does anyone know haw to use a string to access a a javascript object? I need to use a var/string to access a javascript object.
++ This Question has been answered - See the JSFiddle for the fix ++
var answers = {"A":0,"B":0,"C":0,"D":0};
var abcd = $(this).attr("data-filter"); //this is equal to A
var answer_select = "answers."+abcd; //this is equal to answers.A
answer_select=20; //does not change the value.
//if i write..
answers.A=20; //it works
//I need to use the variable "answer_select" as this changes each time..
I have setup a jsfiddle here..
http://jsfiddle.net/jstleger0/h3SEX/6/