Created
May 24, 2019 00:33
-
-
Save SoftwareDevPro/5552636e142bf24bd6120fa92ed9746c to your computer and use it in GitHub Desktop.
Roman Numeral Converter Implementation for Free Code Camp
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
{"index.js":"function convertToRoman(num) {\n\n var decVal = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 ];\n var romanVal = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I' ];\n\n var romanized = '';\n\n for (var index = 0; index < decVal.length; index++) {\n while (decVal[index] <= num) {\n romanized += romanVal[index];\n num -= decVal[index];\n }\n }\n\n return romanized;\n }\n\nconvertToRoman(36);"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment