0
Falsy Bouncer - Remove all falsy values from an array
Hello coders, I'm taking a challenge on FCC where I need to remove all falsy values from an array. There are other ways to solve the problem like filter, but I wanted to try the basic approach first. I'm stuck at a point where If my array element is a falsy value, I want to remove it. But I don't know/remember any method to remove a particular element from an array. Can someone help? Thanks, https://code.sololearn.com/WvaYEIBmjc33
1 Answer
+ 1
[].splice(index, length);
splice removes the index you pass it and length elements from it.
examples:
[].splice(0, 1);
removes element at index 0
[].splice(1, 3);
removes elements at indexes 1, 2 and 3