I have been browsing through the responses here, but none of them seem to work for me. I am trying to remove an item from an array, but no matter what I do, the index keeps returning as -1.
deleteItinerary(id: string) {
this.dataSvc.removeItinerary(id);
console.log('id', id);
const index = this.itineraries.indexOf(id);
console.log('array', this.itineraries);
console.log('index', index);
}
I have read that using array.indexOf() should solve the issue. I am double-checking the id and confirming its presence in the array with console logs, but the index value continues to be -1.
Any assistance would be greatly appreciated. Thank you.