Last active
June 15, 2016 17:01
-
-
Save sophiabrandt/ac0e7a775505018698f50060abcdf925 to your computer and use it in GitHub Desktop.
Revisions
-
sophiabrandt revised this gist
Jun 15, 2016 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,7 @@ function convertToRoman(num) { .set(4, 'IV') .set(1, 'I'); let romanNum =''; // loop over the romanNumbers map and substitute the input number with the roman equivalent for (const [arabicLetter, romanLetter] of romanNumbers) { // destructuring the key value pairs from the map while (num >= arabicLetter) { -
sophiabrandt created this gist
Jun 15, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ function convertToRoman(num) { // create an ES6-map const romanNumbers = new Map() .set(1000, 'M') .set(900, 'CM') .set(500, 'D') .set(400, 'CD') .set(100, 'C') .set(90, 'XC') .set(50, 'L') .set(40, 'XL') .set(10, 'X') .set(9, 'IX') .set(5, 'V') .set(4, 'IV') .set(1, 'I'); let romanNum =''; // loop over the romanNumbers map and substitute the input number with the roman equivalent for (const [arabicLetter, romanLetter] of romanNumbers) { // destructuring the key value pairs from the map while (num >= arabicLetter) { romanNum += romanLetter; num -= arabicLetter; } } return romanNum; }