BioPhoton / BioPhoton/angular-ngrx-refactoring
Filter not working
Open
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have found a mistake in your code.
Please, consider this statment:
.filter((n: any) => {
return n.payload.event.url.indexOf('flight')
})
The indexOf method returns the index of the element or -1 if the element not exists.
However, your filter expects a boolean value (true or false), so under the hood, the value will be converted to boolean. But if you check Boolean(-1) it returns true.
Therefore this filter will always return true.
To make it works you have to compare it with -1:
.filter((n: any) => n.payload.event.url.indexOf('flight')) !== -1
Contributor guide
Assessment
This issue has not been assessed yet.