Still trying to get used to LeetCode format and I don't understand why

this simple solution gets a time limit exceeded error. Any help?

```
/**
* @constructor
* @param {number[]} nums
*/
var NumArray = function(nums) {
this.nums = nums;
};
/**
* @param {number} i
* @param {number} j
* @return {number}
*/
NumArray.prototype.sumRange = function(i, j) {
var sum = 0;
while (i <= j) {
sum += this.nums[i];
i++;
}
console.log(sum);
return sum;
};
```