Skip to content

Instantly share code, notes, and snippets.

@tobiasroeder
Created July 13, 2019 14:22
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 tobiasroeder/42d699b6b692cfac811658f996514b30 to your computer and use it in GitHub Desktop.
Save tobiasroeder/42d699b6b692cfac811658f996514b30 to your computer and use it in GitHub Desktop.
A function which splitter a number.
// 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