In my programming class, I have defined properties like this:
id: number;
motorcycleId: number;
brand: string;
model: number;
year: string;
isDeleted: boolean;
Within my component, there is an array containing instances of this model:
motorcyclesList: MotorcycleModel[];
My goal is to implement a check to see if a new motorcycle being added already exists in the array.
if (this.motorcyclesList.find(x => x.model === this.motorcycle.model &&
x.motorcycleId === this.motorcycle.motorcycleId &&
x.year === this.motorcycle.year)) {
//some logic if exist
}
But so far, the result is always false.