Currently, I am following an older Angular tutorial on Pluralsight that instructs me to input the code below:
performFilter(filterBy: string): IProduct[] {
filterBy = filterBy.toLocaleLowerCase;
return this.products.filter((product: IProduct) => product.productName.toLocaleLowerCase.indexOf(filterBy) !== -1);
}
This code is meant to filter a user search by displaying results containing the letter they typed. However, I am encountering a few errors:
1: [ts] Type '() => string' is not assignable to type 'string'. (parameter) filterBy: string
2: [ts] Property 'indexOf' does not exist on type '() => string'. any
Since I am new to TypeScript, I am unsure if I need to cast these variables or if there is a different solution altogether.