Last active
January 6, 2020 21:59
-
-
Save theneubeck/7e315f373665f2779abd7513170ea116 to your computer and use it in GitHub Desktop.
Pretty Print SEK
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
"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