Guest User

Untitled

a guest
Jan 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // 23 -> 20;
  2. // 234 -> 230;
  3. // 2345 -> 2300;
  4. ...
  5.  
  6. var usersCount = 23;
  7. var rounded;
  8. if (usersCount < 100) {
  9. rounded = Math.floor(usersCount / 10) * 10;
  10. } else if (usersCount < 1000) {
  11. rounded = Math.floor(usersCount / 100) * 100;
  12. } else if (usersCount < 10000) {
  13. rounded = Math.floor(usersCount / 1000) * 1000;
  14. } else if (usersCount < 100000) {
  15. rounded = Math.floor(usersCount / 10000) * 10000;
  16. } else if (usersCount < 1000000) {
  17. rounded = Math.floor(usersCount / 100000) * 100000;
  18. } else {
  19. rounded = usersCount;
  20. }
Add Comment
Please, Sign In to add comment