I have some array like this
roles = ['AnyRulesGo@admin', 'NoRules@admin', 'HowYesNo@history', 'MamaMia@survey'];
And i have some object like this
externalLinks = [
{
link: '#',
icon: 'Icon',
translation: 'Home',
role: '@history',
active: false,
visible: false
},
{
link: '#',
icon: 'Task',
translation: 'Tasks',
role: '@task',
active: false,
visible: false
},
{
link: '#',
icon: 'Files',
translation: 'Files',
role: '@admin',
active: true,
visible: false
}
];
I need some function to check does value role in externaLinks exists in array roles, and update that value visible in externalLinks from false to true
I dont have much more code, because i dont know even where to start from, any help will be great, thanks
One of the problem is that i done have netire role name only started from @ it means I need to cut that string, and than compare?
I have tried with this function, but no luck
function objectsAreSame(x, y) {
var objectsAreSame = true;
for(var propertyName in x) {
if(x[propertyName] !== y[propertyName]) {
objectsAreSame = false;
break;
}
}
return objectsAreSame;
}