DEV Community 👩‍💻👨‍💻

Naveen Dinushka
Naveen Dinushka

Posted on

Using recursion to count from startNum to endNum (freecodecamp notes)

In this exercise we are asked to write a function which should return an array of integers which begins with a number represented by the startNum parameter and ends with a number represented by the endNum parameter.

So deriving from the previous example of countup , here is how this would work

function rangeOfNumbers(startNum, endNum) {

  const rangeArray=rangeOfNumbers(startNum,(endNum-1))

  return rangeArray;
Enter fullscreen mode Exit fullscreen mode

Oldest comments (0)

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!