JavaScript Roman Numeral Converter

Requirements

Implementation

The function convertToRoman(num) converts the given decimal number into a Roman Numeral. num is a positive integer in the range [1 - 3999]. Returns a string representing the Roman Numeral.

Example Usage

Use the browser console to interact with the function (Ctrl + Shift + I, then select the "Console" tab):

> convertToRoman(3); // III
> convertToRoman(29); // XXIX
> convertToRoman(97); // XCVII
> convertToRoman(891); // DCCCXCI
> convertToRoman(1023); // MXXIII
> convertToRoman(3999); // MMMCMXCIX