Given an array of strings as a parameter, I am trying to use the filter method for each string in the array and return matched results.
get moviesByCity() {
return (id: string[]): MovieI[] | undefined => {
console.log(id);
for (let i = 0; i <= id.length; i++) {
console.log(id.length);
console.log(id[i]);
console.log(i);
return this.movies.filter((movie) => movie.city === id[i]);
}
};
}
The issue I'm facing is that 'i' doesn't seem to iterate and stays at '0'. Can anyone spot where I might have made a mistake?
https://i.sstatic.net/2p65d.png
I checked the console.logs in the same order: 'id.length', 'id[i]', and 'i'