JavaScript Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nInitially wanted to make a function variable to keep track of wether we needed to carry
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nInitially wanted to make a function variable to keep track of wether we needed to carry and was attempting to handle the edge case for if we needed to increase the size of the array in an over complicated way.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nLooping through the array starting at the last element, if a digit is a 9 we make it a zero and repeat. When we\'re able to add 1 without going over 9 we should break there, because there is no more work left to do. If we dont\'t find a number that isn\'t 9 (meaning we never reach the else condition in the loop), we should then create a new array with 1 as the first element followed by the array digits that got turned to all 0\'s.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n) \n\n# Code\n```\n/**\n * @param {number[]} digits\n * @return {number[]}\n */\nvar plusOne = function(digits) {\n\n    for(let i = digits.length - 1; i >= 0; i--) {\n        if(digits[i] === 9) {\n            digits[i] = 0\n        }\n        else {\n            digits[i] += 1\n            return digits\n        }\n    }\n\n    return [1, ...digits]\n};\n```
['JavaScript']