/**
* @param {number} num
* @return {string}
*/varintToRoman=function(num){letintegerToRomanMap={1000:"M",900:"CM",500:"D",400:"CD",100:"C",90:"XC",50:"L",40:"XL",10:"X",9:"IX",5:"V",4:"IV",1:"I"};/* In JavaScript, when you compare a number (num) with a string (value), JavaScript implicitly converts the string to a number before making the comparison.*/letresult="";for (letvalueofObject.keys(integerToRomanMap).reverse()){while (num>=value){result+=integerToRomanMap[value];num-=value;}}returnresult;};
Top comments (0)
Subscribe
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)