I have a list of lists which comes from the server in ajax response
has following structure:
var mapping = [ //response.mapping
["userOne", 1],
["userTwo", 2],
["userthree", 3],
["userfour", 4],
["personOne", 1],
["personTwo", 2],
["personOne", 3],
];
As the list will be constant forever, which will have only 7 elements at anytime. I want index of any of its element to update some DOM elements.
// Gives me any of list element which is random elm of the list `mapping`.
var captured_list_elm = process_mapping_list();
var status = mapping.indexOf(captured_list_elm);// getting always -1
Here I'm getting always -1
for status.
- What could be the reason?
- Why indexOf can not calculate its index?
- What's the way to find it, get index through looping over list only?
Created a jsFiddle
NOTE - Actually it should be a json but someone out of our team had written it as a list of lists. I can not update it as of now because the code is in production.