```
var plusOne = function(digits) {
let carry = 1;
for(let i = digits.length - 1; i >= 0; i -= 1) {
if (carry + digits[i] > 9) {
digits[i] = 0;
carry = 1;
} else {
digits[i] += carry;
i = -1;
carry = 0;
}
}
if(carry) {
digits.splice(0, 0, carry);
}
return digits;
};
```