JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

hi guys dont seem to get past this where am i going wrong please anyoe with knowledge

Describe your issue in detail here.

Your code so far

function convertToRoman(num) {
  let romannumerals ={
   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 result = '';
  for (let prop in romannumerals) {
    //console.log(prop);
    //console.log(romannumerals[prop]);
    while(num >= romannumerals[prop]) {
      result -= prop;
    num -= romannumerals[prop];
    }
  }
  return result;
}
convertToRoman(36)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.188

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

Link to the challenge:

What is this line supposed to do?

1 Like

Note - you’ll see more info if you try to console.log(convertToRoman(36)); or similar

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