Skip to content
Advertisement

How to delete the 0’s before the number if the number does not require them?

I’m making a program that prints all possible mixtures of numbers from 0 to 9 and I want to delete the numbers that my code puts before the actual number if the output is less than 6 places.

I’ve tried putting “” before 0 in every array, but it also puts random spaces in the output.

JavaScript

So I want it to output lets say 895 and not 000895. It does that until it reaches 100000, but that’s logical.

Advertisement

Answer

Replace:

JavaScript

By:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement