Jla
August 23, 2020, 3:39am
#1
Tell us what’s happening:
Your code so far
function rangeOfNumbers(startNum, endNum) {
if (endNum - startNum === 0) {
return [];
} else {
var numbers = rangeofNumbers(startNum, endNum - 1);
numbers.push(endNum);
return numbers
}
return [];
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36
.
Challenge: Use Recursion to Create a Range of Numbers
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
sanity
August 23, 2020, 4:31am
#2
Tell us what’s happening. What exactly you are having problem with? What did you try already?
hey bro, you have done a couple of mistakes in your code …
1. remove return[] at the end.
2. var numbers = rangeofNumbers(startNum, endNum - 1); // change 'o' to 'O'
3. if (endNum - startNum === 0) // change to if (endNum - startNum < 0)
tell us what you are trying to achieve