Skip to content
Advertisement

Count occurrences of a given integer in an array using recursion

Without using a loop, I’m trying to count the number of times a given integer is in an array using recursion. I keep getting a StackOverflow error and I can’t figure out why.

JavaScript

}

Advertisement

Answer

If you can use only two parameters, then try:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement