Created
July 13, 2019 14:22
-
-
Save tobiasroeder/42d699b6b692cfac811658f996514b30 to your computer and use it in GitHub Desktop.
A function which splitter a number.
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
// 1234 => 1.234 | |
function splitter(t) { | |
if (t = '' + t, | |
t.length > 3) { | |
var e = t.length % 3, | |
n = e > 0 ? t.substring(0, e) : ''; | |
for (i = 0; i < Math.floor(t.length / 3); i++) n += 0 == e && 0 == i ? t.substring(e + 3 * i, e + 3 * i + 3) : '.' + t.substring(e + 3 * i, e + 3 * i + 3); | |
return n; | |
} | |
return t; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment