I need to find the value of an array and delete it. I have been told that I can do it with .find (). Actually I have not been able to create the correct code in typescript. I have all the values of the array within a for and within that same for, I must find the duplicate array values and take error.
repeatCostCenter() {
for (let found = 0; found < this.costCenterOptions.length; found++) {
let element = this.costCenterOptions[found];
this.costCenterOptions.find()
}
I think of ... If I find that the value of the array [1] is equal to the value of the array [0], print me a message saying that I have two equal values.
I have 5 Array. Each array, has 1 object. Each object has an id. I want to find that id. I want to find the id of an object, after finding that id, look for if that id is duplicated or repeated inside another array.
The id is within the following
setCostCenters(costCenters: GetCostCenterRS[]) {
this.costCenters = costCenters;
this.costCenterOptions = this.costCenters.map(
costCenter => {
const option: SelectItem = {
label: costCenter.CostCenterName,
value: costCenter.id,
};
return option;
}
);
}
The id would be costCenterOption [array] .value.
How do I find that id and see if it is repeated with other arrays?