I have developed a table sorter that handles columns containing both letters and numbers, such as "thing 027". To facilitate sorting, I prepended zeros to the numbers. However, I am now looking for a cleaner way to remove these zeros from the numbers using code. Currently, this is my implementation:
for (var kneecap = 0; kneecap < bronze.length; kneecap++) {
if(isNaN(bronze[kneecap]) === false && bronze[kneecap] === "0"){
if (bronze[kneecap - 1] != 1 && bronze[kneecap - 1] != 2 && bronze[kneecap - 1] != 3 && bronze[kneecap - 1] != 4 && bronze[kneecap - 1] != 5 && bronze[kneecap - 1] != 6 && bronze[kneecap - 1] != 7 && bronze[kneecap - 1] != 8 && bronze[kneecap - 1] != 9) {
bronze[kneecap] = "";
}
Although this code works, I find it quite messy and unpleasant. I would appreciate suggestions on how to optimize this code.
If you need more context to fully grasp the issue, you can access my complete code. (It contains the segment where I eliminate the leading zeros).