Created
February 25, 2020 13:54
-
-
Save toxi-kb/397efab0ba525985fa59111d8f7ae0df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arr = [1, 0, 2, 3, 1, 0]; | |
| // Oops, we have an empty array | |
| const newArray = arr.filter(item => { | |
| if (item === 0) { return item } | |
| }); | |
| // This works properly | |
| const filteredArray = arr.filter(item => item === 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment