You are overcomplicating matters. If the task is to remove random 0s, then just operate on a String.
function removeZeros(n) {
return n.indexOf(0) === n.lastIndexOf(0) ? "Nothing to remove" : n.replace(/0(?!$)/g, "");
}
n argument must be a String. Do you specifically not want to work with a string?
Also[quote=“HovhannesMkoyan, post:1, topic:56626”]
Remove all zeros from the number, except the last one and print the number.
[/quote]
Does this mean except when zero is in the final position or except the last 0 regardless of position? If the latter, use /0(?![^0]*$)/g instead.
wow, I don’t think I can understand what you wrote here, it really is very complicated for me, as I don’t have that much knowledge of JS still. However thanks for helping