JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

Please can someone tell me what is wrong with this my code. I think I got it right but it’s not running and my browser is telling me “ReferenceError: numberValue is not defined”.
Where is the error in my code please?

function convertToRoman(num) {
 const lookupTable = {
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
};

 let accumulator = '';

 for (const key in lookupTable) {
   const numberVlue = lookupTable[key];
   while(numberValue <= num) {
     num -=numberValue;
     accumulator += key;
   }
 }

return accumulator;

}
convertToRoman(36);

   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

Link to the challenge:

that’s because of typo here

Usually reference error means that something is wrong with naming or that you forgot to declare stuff(from my own experience)

Oh! Thank you so much for helping me to point out the error, now I’ve corrected and run my code and it went through. I appreciate.

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