In the hierarchy, the admin should have access to test#1 & test#4, the manager should have access to test#2, and the head should have access to test#3. I attempted to implement this but was unable to meet the requirements.
Check out the link here: https://jsbin.com/cecafeqobo/edit?js,console Below is the snippet of my code:
var mapData = [];
var userList =[{id:2,name:'Admin', users:[{id:2, name:'Test#1'},{id:3,name:'test#4'}]},{id:2,name:'Manager', users:[{id:2, name:'test#2'}]},{id:2,name:'Head', users:[{id:2, name:'test#3'}]}];
userList.forEach(function(element) {
console.log(element.name)
element.users.forEach(function (element) {
mapData.push(element);
})
})
mapData.forEach((element) => {
console.log(element.name);
});