# Spill HackerRank - Tony Lomax
```
/*
* Complete the 'minX' function below.
*
* The function is expected to return an INTEGER.
* The function accepts INTEGER_ARRAY arr as parameter.
*/
function minX(arr) {
let numberFound = false;
let result = 4;
do {
// Make a copy of the current result
let potentialNumber = result;
//Add each number in the array to the potentialNumber
let countUpNumbers = arr.map(arrayNumber => potentialNumber += arrayNumber
);
// Check to see if any of the values in the countUpNumbers array are less than 1
let valuesBelowOne = countUpNumbers.some(addedVal => addedVal < 1);
// If all the values are at least 1 then the current result value is the lowest possible value. Break the loop and...
if (!valuesBelowOne)
{
break;
}
// Otherwise at least one of the calculations caused the number to go below 1. Increment the result and start again.
result ++ ;
}
while (!numberFound);
//... Return the result!
console.log("result", result);
return result;
}
minX([ -10, 4, -3, -7, 20, -7, 45, 0, 60])
```