**Tell us what's happening:**
Describe your issue in detail here.
why is my code not passing??
**Your code so far**
```js
function sumAll(arr) {
var newArr = []
var arr1 = Math.min(arr[0], arr[1])
var arr2 = Math.max(arr[0], arr[1])
for (let i = arr[0]; i <= arr[1]; i++) {
newArr.push(i);
}
return newArr.reduce(function(a, b) {
return a + b;
});
}
console.log(sumAll([1, 4]));

**Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0

function sumAll(arr) {
var newArr = []
var arr1 = Math.min(arr[0], arr[1])
var arr2 = Math.max(arr[0], arr[1])
for (let i = arr[0]; i <= arr[1]; i++) {
newArr.push(i);
}
return newArr.reduce(function(a, b) {
return a + b;
});
}
console.log(sumAll([1, 4]))

If you console.log(i) in your for loop, what values do you see?

The principle of the challenge is to loop between the smallest and largest values, but you have to know which is larger and which is smaller in order to do that. If you don’t you risk the loop not running at all.

You have arr1 and arr2 as a way to find which is which, but now you’ll need to use these.

Given you’re working with a for loop, were would they fit best?

Ok. Consider @8-bitgaming’s response above with the for loop example. If you want to iterate from one number to another number by counting up (i++), you will have to start with the lower number and count up to the higher number. You obviously can’t count from 7 to 4, for example, by adding 1 to 7 each time. You are using Math.min and Math.max to find the lower number and the higher number. You are assigning variables to those values:

You probably want to use those in your for loop instead of always using the first element of the array as the initial value, and the second as the end. As @8-bitgaming illustrated, the code inside the for loop won’t execute when the initial value is higher than the end value.

function sumAll(arr) {
var newArr = []
for (let i = 1; i <= 4; i++) {
newArr.push(i);
}
return newArr.reduce(function(a, b) {
return a + b;
});
}
console.log(sumAll([1, 4]));

We’ll pass you an array of two numbers. Return the sum of those two numbers plus the sum of all the numbers between them. The lowest number will not always come first.

function sumAll(arr) {
let min = Math.min(...arr);
let max = Math.max(...arr);
let addBetween = 0
for (let i = min; i <= max; i++) {
console.log(i)
addBetween += i
}
return addBetween;
}
console.log(sumAll([1, 4]));