Clearing a counter after each function call: JavaScript Recursive function
问题 I have the folllowing solution to a problem relating to multiplicative persistence. However, I need to wipe the counter after each function call. I have tried different return statements, counters and arrays. I don't seem to be able to clear the counter after each function call AND get the correct answer. It is adding all the answers from multiple function calls. function persistence(num, counter = 0) { if (num.toString().length != 1) { num = num.toString().split("").filter(Number).reduce((a,