0
Students
The Romans used the letters of the Latin alphabet to write numbers: I, V, X, L, C, D, M. For example:
- 1 was denoted with the letter I
- 10 with an X
- 7 with VII
The number 2020 in Roman notation is MMXX (2000 = MM, 20 = XX).
solution.js
Implement and export the toRoman()
function that converts Arabic numerals to Roman ones. The function takes an integer between 1 and 3000 and returns a string with the Roman representation of that numeral.
Implement and export the toArabic()
function, which converts Roman numerals to Arabic ones. If the passed Roman numeral is not correct, the function should return false
.
Examples
toRoman(1);
// 'I'
toRoman(59);
// 'LIX'
toRoman(3000);
// 'MMM'
toArabic('I');
// 1
toArabic('LIX');
// 59
toArabic('MMM');
// 3000
toArabic('IIII');
// false
toArabic('VX');
// false
Tips
- Read more about Roman numerals
For full access to the challenge you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.