Tell us what’s happening:
Describe your issue in detail here.
I just want to know why i can,t add 1 to startNum instead of subtracting 1 from endNum and returning it(push endNum, instead of startNum in the second case).
Your code contains global variables that are changed each time the function is run. This means that after each test completes, subsequent tests start with the previous value. To fix this, make sure your function doesn’t change any global variables, and declare/assign variables within the function if they need to be changed.
Example:
var myGlobal = [1];
function returnGlobal(arg) {
myGlobal.push(arg);
return myGlobal;
} // unreliable - array gets longer each time the function is run
function returnLocal(arg) {
var myLocal = [1];
myLocal.push(arg);
return myLocal;
} // reliable - always returns an array of length 2
If by logged my output you mean running the test and completing it, then yes. But only works when i do it using the second example. Btw, thx for answering soo fast!