Hi,
I have an object called checkboxesState and it looks like this,
Object { AS: true, A2: true, GCSE: false, AP: false, KET: false, PET: true, FCE: true, IELTS: false }
I am trying to iterate through this object using each key as a key is a new object called ‘pos’, where these new keys each have a value for ‘r’ (for row) and ‘c’ (for column).
So the object ‘pos’ has objects in it with the same name as the keys in the above object. The ‘r’ and ‘c’ are variously assigned value like this.
for(var prop in checkboxesState){
if(checkboxesState[prop])//generates position object entries for examTypes
{
console.log("exam " + prop + " checkboxesState " + checkboxesState[prop]);
pos = {prop: {r:i,c:j}};
/*var pos = new Object()
pos.prop = i;
prop:c = j;*/
if(j%3 == 2)
{
i++;
j=0;
} else {
j++;
}
}
}
The commented lines and the line directly above them, is where I know that I am going wrong!
I know that I am not creating the object ‘pos’ correctly or the objects within. I should end up with something like this,
pos { AS: {r: 0, c: 0}, A2: {r: 0, c: 1, PET: {r: 0, c: 2, FCE: {r: 1, c: 0} }
‘r’ and ‘c’ values are only added for exam types that are true in the original object checkboxes.
Thanks