Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 23 -> 20;
- // 234 -> 230;
- // 2345 -> 2300;
- ...
- var usersCount = 23;
- var rounded;
- if (usersCount < 100) {
- rounded = Math.floor(usersCount / 10) * 10;
- } else if (usersCount < 1000) {
- rounded = Math.floor(usersCount / 100) * 100;
- } else if (usersCount < 10000) {
- rounded = Math.floor(usersCount / 1000) * 1000;
- } else if (usersCount < 100000) {
- rounded = Math.floor(usersCount / 10000) * 10000;
- } else if (usersCount < 1000000) {
- rounded = Math.floor(usersCount / 100000) * 100000;
- } else {
- rounded = usersCount;
- }
Add Comment
Please, Sign In to add comment