Created
September 30, 2016 11:58
-
-
Save indatawetrust/08cd979d14f9100332ea7970b4fab179 to your computer and use it in GitHub Desktop.
money format
This file contains hidden or 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
var money = function money(num) { | |
var _ = num.split('').reverse(), | |
n = []; | |
for (var i = 0; i < Math.ceil(_.length / 3); i++) { | |
n = n.concat(_.slice(i * 3, i * 3 + 3), ","); | |
} | |
n.pop(); | |
return n.reverse().join(''); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment