Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
index.js
function inclusiveArrayParamRecursive(startVal, endVal) {
if(startVal >= endVal) {
return [startVal]
} else {
const arr = inclusiveArrayParamRecursive(startVal, endVal - 1)
arr.push(endVal)
return arr
}
}
console.log('recursive inclusive array solution: ', inclusiveArrayParamRecursive(2, 6))
// Base Case sets the loop paramenters to return the startVal. Once the start value equals end value we return the call stack to unwind.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment