I like the short solutions that hardcode XC, etc.
I opted to stick with single Roman digits only, so my code is a bit more complicated.
function convertToRoman(num) {
var roman = "";
var numbers = [
[1000, "M"],
[500, "D"],
[100, "C"],
[50, "L"],
[10, "X"],
[5, "V"],
[1, "I"]
];
for(var p = 0; p < numbers.length; p++){
//check for numbers that don't require subtraction
var c = Math.floor(num / numbers[p][0]);
num %= numbers[p][0];
roman += numbers[p][1].repeat(c);
//that would be enough for long-form roman numbers...
//check for subtraction - style numbers
//only if not at 1 already
if(numbers[p][0] > 1){
var d = 1;
//if next highest roman numeral is half of current one, go to the next
//because numbers like VX are pointless, VX == V
if (numbers[p][0]/numbers[p+d][0] == 2) {d=2;}
if (num >= numbers[p][0]-numbers[p+d][0]){
num -= numbers[p][0]-numbers[p+d][0];
roman += numbers[p+d][1]+numbers[p][1];
}
}
}
return roman;
}