# A little nudge to get started

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

hi everyone. as you see , i hardly started on this project but . i just need a nudge in the right direction. i know theres gotta be a way to pass all tests without writing 4000 case statements. . thank you in advance

``````   **Your code so far**
``````
``````
function convertToRoman(num) {
return num;
}

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

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

Challenge: Roman Numeral Converter

Start smaller. Think about the numbers from 1 to 8. There are only 3 cases to consider. What are they?

i just know that after III (roman number of 3) , you put a V before the one to make 4, then V becomes five and keep incrementing an I after that from 5-8

Exactly.

So, if num >= 5, then ________

If num == 4, then________

If num >=1, then________

Just as encouragement, yeah, I remember this as being a tough one for me. There are a couple of upcoming ones that hurt my brain. Just keep at it and don’t get frustrated. And follow Jeremey’s advice.

1 Like

thanks alot. that makes more sense. the smalller case is much easier but, its a start.

thanks alot . im actually looking forward to this project. i m bad at roman numerals so this is a project i can apply for personal use. i actually never thought i see the end of intermediate algorithms and now i can do the basic algorithms with no issues. so im pumped.

I always struggled with remembering Roman numerals until I learned the mnemonic: I Value Xylophones Like Cows Do Milk. That’s 1, 5, 10, 50, 100, 500, 1000.

i love that analogy. a xylophone is a great instrument too.

well heres a start. but i can see this is going to be a mess further on.

``````function convertToRoman(num) {
let max=num;
let result=''

for(let i = 1; i <= max; i++){
if (i >=1 && i<=3)
result=result+'I';

if (i ===4)
result="IV"

if (i ===5)
result= "V"

if (i > 5)

result=result+'I';

}
num=result
console.log(num)
return num;
}

convertToRoman(8);
``````

Hmm, good start but that won’t quite work. Think about it as if you were making change. 8 is one 5 and 3 ones.

yeah good point. i was just trying to just get something started

im just trying to hard code it til 100 just to get a repetitive pattern in my head to see the best way to simplify it to find the right algorithm. im not in a rush here.

thanks alot . i finally figured it out. after doing a bunch of mind teasing, those 3 cases u mentioned winded up being the 3 fundamental cases. it was just number matching and setting the right limits after that and string manipulation. im not 100% sure why it work after thatbut i was doing few cases at a time and more tests passed.

oh when i was stjuck earlier on , i found out u can still complete the project by hard coding it by setting the values === to the test parameters by using multiple if or switch.
but i went through to figure it out the right way.

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