Created
December 20, 2015 14:44
-
-
Save justincorrigible/07d02bd20426c7769e5b to your computer and use it in GitHub Desktop.
Bonfire: Roman Numeral Converter
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
function convert(num) { | |
var x = ''; | |
[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1].map( | |
function(obj,i){ | |
while (num>=obj){ | |
x+=['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'][i]; | |
num-=obj;}}); | |
return x; | |
} | |
convert(36); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Convert the given number into a roman numeral.
All roman numerals answers should be provided in upper-case.