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
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
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.
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: IValue Xylophones Like Cows Do Milk. That’s 1, 5, 10, 50, 100, 500, 1000.
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);
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.