BioPhoton / BioPhoton/angular-ngrx-refactoring

Filter not working

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.