trying to map two Array Values. One Array Values are coming from the local Json file and other array values are coming from the service or backend.
Local JSON:
var localJsonArray = {
"records": {
"cat1": [{
"id": 1234,
"label": "a"
}, {
"id": 2345,
"label": "b"
}],
"cat2": {
"id": 12345,
"label": "c"
}
}
}
Backend Array Values:
I am storing the value coming from backend as:
var backendArray =[0: "1234", 1: "3456", 2:"4567"];
JS:
$.each( localJsonArray, function( key, value ) {
var index = $.inArray( value, backendArray );
if( index != -1 ) {
console.log( index );
}
});
Now how do I map the id of local Json to the id of backend JSON. If value matches the loop should break else it should look for the value.