Basically what I've got is:
var x= 0;
var a = "";
if (x=0) {a = "key"} else {a = "other"};
var obj = {};
obj[a] = "studentphoto";
x changes based on a different function, so at this point the object looks like:
obj = {"key":"item"};
now the variable x changes so when I call up the item with:
var j = obj.x
Naturally it does not work because there is no key "x" in my object.
What I would like to know is whether there is a way to have a variable that changes be the key to call up the objects item, or if I should find a better way to do it?