I am working on a function that involves a checkbox functionality and I want it to check to see if the value selected is already in the array, and if so remove it. This would be the case when someone "unchecks" the checkbox.
checkedCodes: any = [];
searchResultsCheckBox = (e) => {
var row = e.target.parentNode.parentNode;
var charge = row.getElementsByClassName('chargeList')[0] as HTMLElement;
var description = row.getElementsByClassName('descriptionList')[0] as HTMLElement;
this.selectedCode = charge.innerText + " (" + description.innerText + ")";
if (this.checkedCodes.includes(this.selectedCode)){
// What should I put here?
}
else {
this.checkedCodes.push(this.selectedCode);
}
}
I want something in the if statement to check to see if the selectedCode is already in the array checkedCodes and if so remove it. Any suggestions will help