Fullstack developer for a midsized telecommunications company located in southern Indiana. Programming languages and compilers enthusiast. Striving to get 1% better every day.
The whole way down the post I was asking myself "why not just use Array.reduce() and then you mentioned it at the end. 😂
Succinct explanation though, and since AFAIK no widely used JavaScript engine implements tail call optimization it's likely that having a base folding function that uses a for loop instead of recursion will be necessary for data sets of a certain size.
Well done, though.
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.
The whole way down the post I was asking myself "why not just use
Array.reduce()
and then you mentioned it at the end. 😂Succinct explanation though, and since AFAIK no widely used JavaScript engine implements tail call optimization it's likely that having a base folding function that uses a for loop instead of recursion will be necessary for data sets of a certain size.
Well done, though.