# Roman Numeral Converter - I look for critics!

After finishing the Roman Numeral Converter project, which is one the projects required in the Javascript Algorithms and Data Structures course. I checked some topics about it. I noticed some of those solutions used two lists, one with decimal numbers and the other one with roman numbers. I did it with one list only, the one with roman numbers. I would appreciate if you give me any feedback, critics or suggestion.

``````function convertToRoman(num) {
let result = '';
let count = 0;
let list = [];
let str = num.toString();
let romans = [['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'], ['', 'M', 'MM', 'MMM']];

for (let i = str.length - 1; i > -1; i--) {
list.push(romans[i][parseInt(str[count])]);
count += 1;
}

for (let i = 0; i < list.length; i++) {
result += list[i];
}

return result;
}

convertToRoman(44);
``````

Iâ€™ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the â€śpreformatted textâ€ť tool in the editor (`</>`) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (â€™).

1 Like

@lasjorg Oh I see, I didnâ€™t know how to do that. Thank you!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.