DEV Community

davidka7
davidka7

Posted on

Call the function inside that function

Sometimes instead of just a loop, you might need a more descriptive tactic. A cool trick is if you need the same functionality to be repeated again you can just call the function again inside the function. Just make sure to break otherwise it might go into an infinite loop.

function hitAgain(number, boolean) {
number +=1
if (boolean == false)
{
}
number += hitAgain(number, false)

return number

}

hitAgain(1, true)

Top comments (1)

Collapse
 
clavinjune profile image
Clavin June

yes, and that's called recursion