Skip to content

Instantly share code, notes, and snippets.

@mul14
Created December 28, 2014 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mul14/29ad7ec5a90530be255a to your computer and use it in GitHub Desktop.
Save mul14/29ad7ec5a90530be255a to your computer and use it in GitHub Desktop.
jEMpmP
function fancyAmount(numbers) {
var numbers = String(numbers);
var small = numbers.substr(numbers.length -3)
.replace(/(.+)/, "<small>$1</small>");
return numbers.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.')
.replace(/(\d{0,3}$)/, small);
}
body = document.querySelector('body');
body.innerHTML = fancyAmount( 1234567890 );
body {
font-size: 32px;
text-align: center;
}
small {
font-size: 24px;
color: gray;
vertical-align: super;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment