Whenever you are stuck with a project and don’t understand why the tests are failing, always run through your code using one of the test cases.
Test out your code using this function call convertToRoman(4)
Right now that function call returns IIII which is incorrect.
Think through the logic of your current code here
for (var key in romanToNum) {
//while 4 is greater than or equal to 1
while (num >= romanToNum[key]) {
//add I to the roman variable
roman += key;
//subtract 1 from num
num -= romanToNum[key];
}
}
Now take a look at your object
You will need to rethink the ordering for that object.
Once you make that change to the object then the test will pass.