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);