Last active
April 19, 2021 19:02
-
-
Save osahondev/8d14387f1d2c031b364c823cc6db2c4b to your computer and use it in GitHub Desktop.
Function to remove instances from a value and return new length
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 elementRemoval = (nums,val) =>{ | |
| if( nums == undefined ) | |
| return 0 | |
| return nums.filter( num=>num!=val ).length; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the feedback. On a second look at other implementations, perhaps there truly is a better way. I would study them to improve on my efficiency. Keep up the good work by the way. Really love Algo Friday.