# Post your Roman Numeral Converter solutions here! (Fall 2022)

**URL:** <https://group.classcentral.com/t/post-your-roman-numeral-converter-solutions-here-fall-2022/35779>\
**Category:** JavaScript Bootcamp\
**Created:** [September 21, 2022, 8:30am UTC](https://group.classcentral.com/t/post-your-roman-numeral-converter-solutions-here-fall-2022/35779 "2022-09-21T08:30:22Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![stevenr2945563](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@stevenr2945563](https://group.classcentral.com/u/stevenr2945563)\
**Post date:** [September 28, 2022, 12:31pm UTC](https://group.classcentral.com/t/post-your-roman-numeral-converter-solutions-here-fall-2022/35779/32 "2022-09-28T12:31:19Z")

</div>

Here’s my solution. I can now see that many of the other, more efficient solutions are essentially doing the same thing as I’m doing, except instead of the copy-paste of each block in the `if-else`, the equivalent to the concatenation is implemented once, and objects are created to map the Roman numerals onto their specific values.

In that case, my question is: how does one gain the intuition to simplify the process in these ways? Is it just a matter of time/doing exercises/reading other people’s solutions and learning from them?

```auto
function convertToRoman(num) {
 let countDown = num;
 let romanStr = "";
 while (countDown > 0){
   if (countDown >= 1000) {
     romanStr += "M";
     countDown -= 1000;
     continue;
   } else if (countDown >= 900) {
     romanStr += ("CM");
     countDown -= 900;
     continue;
   } else if (countDown >= 500) {
     romanStr += ("D");
     countDown -= 500;
   } else if (countDown >= 400) {
     romanStr += ("CD");
     countDown -= 400;
   } else if (countDown >= 100) {
     romanStr += ("C");
     countDown -= 100;
   } else if (countDown >= 90) {
     romanStr += ("XC");
     countDown -= 90;
   } else if (countDown >= 50) {
     romanStr += ("L");
     countDown -= 50;
   } else if (countDown >= 40) {
     romanStr += ("XL");
     countDown -= 40;
   } else if (countDown >= 10) {
     romanStr += ("X");
     countDown -= 10;
   } else if (countDown >= 9) {
     romanStr += ("IX");
     countDown -= 9;
   } else if (countDown >= 5) {
     romanStr += ("V");
     countDown -= 5;
   } else if (countDown >= 4) {
     romanStr += ("IV");
     countDown -= 4;
   } else if (countDown >= 1) {
     romanStr += ("I");
     countDown -= 1;
   
   }
 }
 
 return romanStr;
}

console.log(convertToRoman(36));

```

---

_[View the full topic](https://group.classcentral.com/t/post-your-roman-numeral-converter-solutions-here-fall-2022/35779)._
