JavaScript Algorithms and Data Structures Projects - Roman Numeral Converter

Tell us what’s happening:
Describe your issue in detail here.

In Case anybody is looking for a simple solution
Your code so far

function convertToRoman(num) {
let obj={
  "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 str="";

while(num>0){
 for(let i in obj){
   if(num>=obj[i]){
     str+=i;
     num-=obj[i];
     break;
   }
 }
}
return str
}

convertToRoman(36);
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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:

Hi, welcome to the forum.

We don’t normally post working code like that, especially if it is a working solution to a curriculum challenge, which is why I wrapped it in [spoiler][/spoiler] tags.

I apologize I wasn’t aware

2 Likes

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