Enter the number n to print out the largest n decimal digits in sequence. For example, if you type 3, you print 1, 2, 3 up to 999.
Example 1:
Input: n = 1 Output: [1,2,3,4,5,6,7,8,9]Copy the code
Description: Return a list of integers instead of printing n as a positive integer
Math.pow() returns a power of the base exponent.
var printNumbers = function(n) {
var target = Math.pow(10,n);
var result = [];
for(var i = 1; i < target; i++){
result.push(i);
}
return result;
};
Copy the code