0
Why does this output 1, even if i set it's "index" value to anything above 1 or 2?
var numberBefore; var numberNow; var index; index = 10; if (index == 0){ document.write("Invalid Number"); }else if((index==1)||(index==2)){ document.write(1); }else{ numberBefore = 1; numberNow = 1; for (var i=0;i<=index;i++){ numberBefore = numberNow; numbernow = numberNow + numberBefore; } document.write(numberNow); }
2 ответов
0
JavaScript is a case sensitive language. You have to change „numbernow“ to „numberNow“ in the loop.
0
i... cant... believe...it was that