Hi All,
could someone please provide me with some hints for the following code,
I was hoping the while loop would work, however, it’s not completing the challenge, and I hope some fresh eyes will be able to see something I can’t,
Many Thanks
**Your code so far**
function convertToRoman(num)
//Roman Numeral values
{let romanNum = {
M: 1000,
CM: 900,
D: 500,
CD: 400,
C: 100,
XC: 90,
L: 50,
XL: 40,
X: 10,
IX: 9,
V: 5,
IV: 4,
III: 3,
II: 2,
I: 1
};
// Variable to allow the keys to get moved into.
let converted = '';
// While loop to see if the num value is greater than said key before moving through rest of keys, and adding to converted variable.
for (let key in romanNum) {
const number = romanNum[key];
while (number <= num)
{num -= number;
converted =+ key;
}
}
return converted;
}
convertToRoman(36);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36
Challenge: Roman Numeral Converter
Link to the challenge: