Created
April 10, 2020 16:05
-
-
Save kulcsarrudolf/4a908ef853cf3811c0145cde2eeea9bb to your computer and use it in GitHub Desktop.
Use Recursion to Create a Range of NumbersPassed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Create a Range of Numbers | |
| function rangeOfNumbers(startNum, endNum) { | |
| if (startNum === endNum) { | |
| return [startNum]; | |
| }else { | |
| const rangeArray = rangeOfNumbers(startNum, endNum-1); | |
| rangeArray.push(endNum); | |
| return rangeArray; | |
| } | |
| }; |
Author
kulcsarrudolf
commented
Jun 14, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment