Hello, I just solved the sum all numbers in a range challenge but I got a strange behavior in the process

I first did this…

```
var total = 0;
function sumAll(arr) {
var min = Math.min.apply(null, arr);
var max = Math.max.apply(null, arr);
for(var i = min; i <= max; i++){
total += i;
}
return total;
}
sumAll([5, 10]);
```

only the first test that checks if the output is a number passed, though the outputs were correct. However, when I did the following, which is basically changing the scope of the total variable, it was accepted

```
function sumAll(arr) {
var min = Math.min.apply(null, arr);
var max = Math.max.apply(null, arr);
var total = 0;
for(var i = min; i <= max; i++){
total += i;
}
return total;
}
sumAll([5, 10]);
```

WHY???