A Pen by Mulia Arifandy Nasution on CodePen.
Created
December 28, 2014 04:32
-
-
Save mul14/29ad7ec5a90530be255a to your computer and use it in GitHub Desktop.
jEMpmP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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