Looking for a way to optimize my function that checks for repeated cell phone numbers in a list. Currently, I am using nested for loops and wondering how I can implement functional programming instead?
checkDuplicate(): boolean {
for (let i = 0; i < this.phoneList.length; i++) {
for (let j = 0; j < this.phoneList.length; j++) {
if (i != j) {
if (this.phoneList[i].number === this.phoneList[j].number) {
this.toastrService.error('Phone already in List!');
return true;
}
}
}
}
return false;
}