Tell us what’s happening:
Describe your issue in detail here.
I am trying to understand what “" means in solution 4 of “Factorialize a Number”. I understand the other solutions in “Factorialize a Number”, but I’m trying to understand “tail recursion”. So what does "” mean? I found the underscore library. Is that what “_” refers to in this code?
The “underscore library” refers to lodash, I believe - which isn’t what is being used here.
An underscore used in a function’s parameters indicates a parameter that isn’t going to be used in the function’s code. In this case, the reduce method’s callback accepts up to 4 values, but the code isn’t using the second value so replaces the parameter with the underscore.
It’s basically a “workaround” for function parameter/argument order.
In the example code, the currentValue isn’t used but the code still needs access to the index and you can’t just do (previousValue, currentIndex) as that would make the currentIndex the currentValue. The order has to be (previousValue, currentValue, currentIndex).
So if you do not need the current value you can do (previousValue, _, currentIndex).