educative.io

Educative

https://www.educative.io/module/lesson/javascript-basics/RLxwqVRqgDV

var rangeSum = function(number) {

console.log(number);

var sum = 0;

for(var i=0; 0< i <=number; i++)

{

sum =sum+number;

}

return sum ;

}


###### Output

30.62s

-30 0 30

Execution Timed Out!

how i fix this time out error
----
Type your question above this line.

Course: https://www.educative.io/collection/10370001/5686791109607424
Lesson: https://www.educative.io/collection/page/10370001/5686791109607424/5740423507083264

@ohm The problem occurs at this position where you are using double conditions without using AND or OR.

for(var i=0; 0< i <=number; i++)

If you want to check both conditions then do use && like this:

for(var i=0; 0< i && i<=number; i++)

Hope it helps!!