Hey everyone,
I have a question that might seem silly, but I'm feeling stuck and could use some assistance.
So, I have two sets of data - one is an object structured like this:
var userData = {
"2_6": {
"name":"John Doe",
"location":"New York"
},
"2_70": {
"name":"Jane Smith",
"location":"Los Angeles"
},
"2_59": {
"name":"Michael Johnson",
"location":"Chicago"
}
And the other set is an array representing a specific order:
var userOrder = ["2_70", "2_59", "2_6"];
My problem arises when I try to log the names from the userData in the order specified by userOrder using jQuery. Here's what I have so far:
$.each(userOrder, function(key)
{
console.log(userData[key].name);
}
In theory, this should output the names from the userData based on the userOrder sequence, but unfortunately it's not working as expected. Any suggestions or tips would be greatly appreciated! Thank you!