I am getting the name of the user everytime the script is called and storing it in a variable called name
And I have a object which is initially null and I want it to be populated based on the name that I read.
I have this object
var usernames = {
name1: {
name: "ajey",
room: 1,
isStudent: true,
isTeacher: false
},
name2: {
name: "ajey-teacher",
room: 1,
isStudent: false,
isTeacher: true
},
name3: {
name: "batman",
room: 2,
isStudent: true,
isTeacher: false
}
};
Later I would print all the objects along with its key and value in the usernames object like,
for(var i in usernames) {
console.log(i.name1.name);
}
Here is the fiddle I am working on but I am having some issues. Demo