All done - a very basic approach from me:
var oneToNine = ["","I","II","III","IV","V","VI","VII","VIII","IX"];
var tens = ["","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"];
var hundreds = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"];
var thousands = ["M","MM","MMM"];
function convertToRoman(num) {
var numArr = num.toString().split("");
if (numArr.length === 1){
return oneToNine[num];
}
else if (numArr.length === 2){
return tens[numArr[0]] + oneToNine[numArr[1]];
}
else if (numArr.length === 3) {
return hundreds[numArr[0]]+tens[numArr[1]] + oneToNine[numArr[2]];
}
else if (numArr.length === 4){
return thousands[numArr[0]-1]+hundreds[numArr[1]]+tens[numArr[2]] + oneToNine[numArr[3]];
}
}
convertToRoman(1232);