Skip to content

Instantly share code, notes, and snippets.

@justincorrigible
Created December 20, 2015 14:44
Show Gist options
  • Save justincorrigible/07d02bd20426c7769e5b to your computer and use it in GitHub Desktop.
Save justincorrigible/07d02bd20426c7769e5b to your computer and use it in GitHub Desktop.
Bonfire: Roman Numeral Converter
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);
@justincorrigible
Copy link
Author

Convert the given number into a roman numeral.
All roman numerals answers should be provided in upper-case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment