这是一些对你有帮助的资源:
哇这个这个我看不懂
function convert(num) { var nums = [1000,900,500,400,100,90,50,40,10,9,5,4,1]; var romans =["m","cm","d","cd","c","xc","l","xl","x","ix","v","iv","i"]; var str = ''; nums.forEach(function(item,index,array){ while(num >= item){ str += romans[index]; num -= item; } }); return str.toUpperCase(); } convert(36);
这个是CSDN上
Icebela
的做法,原谅我看不懂我真的看不懂。