Hello guys,

I have JS exerceise to solve. After trying a lot of times I would like to get a help,please.

*Insert a number. Remove all zeros from the number, except the last one and print the number. If there are at most one zero, print “Nothing to remove”.*

*4050120 ---- 45120*

*7845012 ----- “Nothing to remove.”*

*0 ----- “Nothing to remove.”*

Thanks in advance.

Below is what I have done till now.

```
var number = +prompt("Enter a number");
var sameNumber = number;
var numberOfZeros = 0, lastDigit = sameNumber % 10;
while (number !== 0) { // checking case of one 0
if (number % 10 === 0) {
numberOfZeros++;
}
number = Math.floor(number / 10);
}
if ((numberOfZeros === 1) || (sameNumber === 0)) {
console.log("Nothing to remove");
} else {
var currentDigit = sameNumber % 10;
while (sameNumber !== 0) {
if (currentDigit === 0) {
}
sameNumber = Math.floor(sameNumber / 10);
}
}
```