Filter loops through every item in an array and 'v' is a placeholder/variable that represents the current item. 'v' can be any name you choose. Since this problem does not require using the current item, it serves no purpose. Many times you'll encounter a _ variable when a function parameter is planned on being unused.
we thought of same solution lol
thank you!)
"v" is unused, it is needed because by default first parameter is current element and second is index.
May someone explain me the use of 'v' in filter method here?
Oh, thanks. I just thought this would be O(6n).
It seems I need learn more about the time complexity.
Is this the Best Practices?
It runs the loop so many times, and that can be optimize.
Thank you)
Filter loops through every item in an array and 'v' is a placeholder/variable that represents the current item. 'v' can be any name you choose. Since this problem does not require using the current item, it serves no purpose. Many times you'll encounter a
_
variable when a function parameter is planned on being unused.Who can explain, what v it means?
It means your code returns
undefined
(if JS, probably you return nothing), while it must return a boolean.This comment is hidden because it contains spoiler information about the solution