Skip to content

Instantly share code, notes, and snippets.

@theneubeck
Last active January 6, 2020 21:59
Show Gist options
  • Save theneubeck/7e315f373665f2779abd7513170ea116 to your computer and use it in GitHub Desktop.
Save theneubeck/7e315f373665f2779abd7513170ea116 to your computer and use it in GitHub Desktop.
Pretty Print SEK
"use strict";
function pn(number) {
const str = number.toString();
const chunks = ["SEK"];
for (let i = 0; i < str.length; i += 3) {
chunks.unshift(str.substring(str.length - i - 3, str.length - i));
}
return chunks.join(" ");
}
function ppn(number) {
const str = number.toString();
let result = "SEK";
for (let i = 0; i < str.length; i += 3) {
result = str.substring(str.length - i - 3, str.length - i) + " " + result;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment