Recursion in JavaScript

Daphne Watson
1 min readFeb 17, 2017

A nice to summarize recursion: the ability for a function to call itself until arriving at an expected result. Recursion is a concept used in computer science and for problem solving.

I learned to code recursive functions with factorials. In mathematics, the factorial of an integer n (with a value greater than zero) is the product of all positive integers less than, or equal to n. For example —

Factorial of 4 equals 24
Factorial of 3 equals 6

Factorials are a great way to practice coding with recursion, because we are multiplying over the integer value n until arriving at the expected result.

My solution for using factorial integers with recursion is as follows:

Recursive function in JS using factorials

-D.

--

--