Duplicate check in multidimesional arrary in javascript expression

1
0
-1

I have a an attribute which is multiple in bdm

now my requriement is i need to do validation for this multiple attributes such that values are not repeating so

I have written javascript expression

my approveObj looks like below :I should return a boolean value if duplicate founf in approvers

[{"minMaxInfoId":0,"levelOfApprovers":1,"approvers":["Immediate Manager","DU Head"]},{"minMaxInfoId":0,"levelOfApprovers":2,"approvers":["DU Head","Procurement Committee"]}]

let result=false;
var approverObj= $data.formInput.approverLevelsInfoInput;
var app = approverObj.map(a => a.approvers);
var arr=JSON.stringify(app);
//console.log(JSON.stringify(app))

let findDupesInMDArray = (arr) => {
// flatten the array
const flat = arr.flat();
console.log(flat);
// filter for dupes
var isDuplicate= flat.filter((item, index) => flat.indexOf(item) != index);//here iam filtering for duplicates but how can i check for and return //a boolean values
console.log(isDuplicate);

}

// if(result) {
// return true;
// } else {
// return false;
//}
Please suggest . I have tried multiple codes but nothing works.

No answers yet.
Notifications