So I have (finally) completed the Credit Card Checker project, which can be found here

While doing some research for the project, I came cross ChildOfCode.com and found this very clean code (below) for validating credit cards using the Luhn algorithm. My question is, how does he use the `var doubleUp = false;`

in order to double every other number in the array (as the algorithm specifies)? Thanks in advance!

```
/* Luhn Algorithm JavaScript by childofcode.com */
function LuhnAlgorithm(num){
var inputNum = num.toString();
var sum = 0;
var doubleUp = false;
/* from the right to left, double every other digit starting with the second to last digit.*/
for (var i = inputNum.length - 1; i >= 0; i--)
{
var curDigit = parseInt(inputNum.charAt(i));
/* double every other digit starting with the second to last digit */
if(doubleUp)
{
/* doubled number is greater than 9 than subtracted 9 */
if((curDigit*2) > 9)
{
sum +=( curDigit*2)-9;
}
else
{
sum += curDigit*2;
}
}
else
{
sum += curDigit;
}
var doubleUp =!doubleUp
}
/* sum and divide it by 10. If the remainder equals zero, the original credit card number is valid. */
return (sum % 10) == 0 ? true : false;
};
```