Freecodecamp keeps telling me TypeError: converter is not a function, when I go to solve this problem.
Your code so far
function convertToRoman(num) {
var converter = {
M : 1000,
CM : 900,
D : 500,
CD : 400,
C : 100,
XC : 90,
L : 50,
XL : 40,
X : 10,
IX : 9,
V : 5,
IV : 4,
I : 1,
};
var roman = "";
for (var key in converter){
while (num >= converter([key])){
roman += key;
num -= converter([key]);
}
}
return roman;
}
convertToRoman(36);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/117.0
Challenge: JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter
Link to the challenge: