Skip to content

Commit

Permalink
added Fucntion
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricechouam committed Jan 11, 2021
1 parent 944375d commit 0241133
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Plus One/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* @param {number[]} digits
* @return {number[]}
*/
var plusOne = function(digits) {
for(let i =digits.length-1; i>=0; i--){
if(digits[i]!==9){
digits[i]++
return digits
}
else{
digits[i]=0;
}
}
digits.unshift(1);
return digits
};

0 comments on commit 0241133

Please sign in to comment.