Having the following dataset:
roles = [
{roleId: "69801", role: "ADMIN"}
{roleId: "69806", role: "SUPER_ADMIN"}
{roleId: "69805", role: "RB"}
{roleId: "69804", role: "PILOTE"}
{roleId: "69808", role: "VENDEUR"}
{roleId: "69807", role: "SUPER_RB"}
]
The objective is to filter the table and check if there is an object containing a specific role value.
The function to achieve this would be as follows:
checkRoleExistence(role){
// Return true if role exists in any of the objects, else return false
}
To use it, one could call the function like this:
let ifExists = this.checkRoleExistence("PILOTE") ;
One idea for implementing this is to utilize the "filter" function from Ecmascript.
Any suggestions or improvements?