JSFiddle - React, Tailwind, and code Playground

by bilbobaggins

JavaScript

var authors=[{"RoleID":45,"Rolename":"asd","isactive":"True","ModID":"13","Modulename":"inventory","Accestype":"AA,VO","mroleID":"96,97,98"},{"RoleID":46,"Rolename":"admin","isactive":"True","ModID":"13","Modulename":"inventory","Accestype":"AA","mroleID":"96,97,98"}]
var books=[{"code":"AA","label":"allaccess"},{"code":"VO","label":"viewonly"}]


   var doct = authors.map(function(doctor) {
    return { // return what new object will look like
        RoleID: doctor.RoleID,
        Rolename: doctor.Rolename,
        isactive: doctor.isactive,
        Accestype: doctor.Accestype.split(','),
        baseAccestype: doctor.Accestype,
        Modulename: doctor.Rolename,
        mroleID: doctor.isactive,
    };
});
console.log(doct)

for (i = 0; i < doct.length; i++) { 
    
    for (j = 0; j < doct[i].Accestype.length; j++) { 
    

    var internaccesstype=doct[i].Accestype[j]
    console.log(doct[i].RoleID)
        console.log(internaccesstype)
       
    var intred = books.filter(function(doctor) {
    return doctor.code === internaccesstype; // if truthy then keep item
})
    console.log(intred[0].label)
    
}
    
}