In tail recursion is better. It's optimized by the JavaScript engine and will not fill the heap at any call, and will have the same space complexity of an iterative one.
And as a plus can be a one liner.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In tail recursion is better. It's optimized by the JavaScript engine and will not fill the heap at any call, and will have the same space complexity of an iterative one.
And as a plus can be a one liner.