List of utility methods to do Number to Roman Number Convert
to_roman()mapa = {0:"", 1:"I", 5:"V", 10:"X"} lista = [0, 1, 5, 10] Number.prototype.to_roman = function() { if(this in mapa) return mapa[this] var num = menor_que(this, mapa) if((this+num) in mapa) return num.to_roman() + (this+num).to_roman() return num.to_roman() + (this-num).to_roman() function menor_que(num, mapa) { ... | |
convertToRoman(number)String.prototype.reverse=function(){return this.split("").reverse().join("");} function { var romanNumValueArr = [ {num: "I", value: 1}, {num: "V", value: 5}, {num: "X", value: 10}, {num: "L", value: 50}, {num: "C", value: 100}, {num: "D", value: 500}, ... |