Suhail - 5 months ago 11x

Javascript Question

I am having a asp application and in that amount column is there. I need to find out how many thousands and hundreds and tens are there in that amount

For example

if i am having amount as 3660 means

1000's - 3

100's - 6

10's - 6

like this i need

Can any body help me

Answer

The simple answer is to divide the number by 1000 whatever is the quotient that is the number of 1000's in the amount. Then divide the remainder with the 100's the quotient will be the number of 100's. And then again divide the remainder with 10, the quotient will be the number of 10's

Something like this:

```
quotient = 3660 / 1000; //This will give you 3
remainder = 3660 % 1000; //This will give you 660
```

Then,

```
quotient1 = remainder/ 100; //This will give you 6
remainder1 = remainder % 100; //This will give you 60
```

And finally

```
quotient2 = remainder1 / 10; //This will give you 6
```

Source (Stackoverflow)

Comments