I am working on the Roman Numeral Converter project found here. I cannot get it to pass any tests, but it seems to work fine on Repl.it. I also cannot get it to go over 3,999 on Repl.it. Thanks for any help.

function convertToRoman(num) {
let numArr = num.toString().split("");
let regNumArr = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000];
let romNumArr = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"];
let j = 0;
let romNumArrFinal = [];
let romNumStrFinal = "";
for(i = numArr.length - 1; i >= 0; i--) {
let tempNum = numArr[i] * Math.pow(10, j);
let firstDigit = Number(numArr[i]);
switch (firstDigit) {
case 1:
case 4:
case 5:
case 9:
romNumArrFinal.unshift(romNumArr[regNumArr.indexOf(firstDigit * Math.pow(10, j))]);
break;
default:
for (let x = firstDigit; x > 0; x--) {
romNumArrFinal.unshift(romNumArr[regNumArr.indexOf(1 * Math.pow(10, j))]);
}
break;
}
j++;
}
return romNumStrFinal = romNumArrFinal.join("");
}
convertToRoman(2);

In order to get your repl.it environment to behave the same as the freeCodeCamp environment, add "use strict" at the top of your code. This will help you figure out the first problem.

Thanks a lot! That â€śuse strictâ€ť; at the top of the Repl.it console really helped a lot. I was able to pass all of the tests, but this still does not work with numbers larger than 3,999. I will pursue this a little longer before moving to the next challenge.

"use strict";
function convertToRoman(num) {
let numArr = num.toString().split("");
let regNumArr = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000];
let romNumArr = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"];
let j = 0;
let romNumArrFinal = [];
let romNumStrFinal = "";
for(let i = numArr.length - 1; i >= 0; i--) {
let firstDigit = Number(numArr[i]);
switch (firstDigit) {
case 1:
case 4:
case 5:
case 9:
romNumArrFinal.unshift(romNumArr[regNumArr.indexOf(firstDigit * Math.pow(10, j))]);
break;
default:
if (firstDigit >= 5) {
romNumArrFinal.unshift(romNumArr[regNumArr.indexOf(5 * Math.pow(10, j))]);
firstDigit -= 5;
for (let x = firstDigit; x > 0; x--) {
romNumArrFinal.splice(1, 0, romNumArr[regNumArr.indexOf(1 * Math.pow(10, j))])
}
}
else {
for (let x = firstDigit; x > 0; x--) {
romNumArrFinal.unshift(romNumArr[regNumArr.indexOf(1 * Math.pow(10, j))])
}
}
break;
}
j++;
}
return romNumStrFinal = romNumArrFinal.join("");
}
convertToRoman(2020);

Itâ€™s good that you used a spoiler since this it is a working example of one of the projects, but we canâ€™t copy paste and see whatâ€™s happening. Are you getting an error of some sort?

I will also note that 4,000 is another break point in roman numerals because 5,000 is V with lineover so 4000 = MV

edit: after I wrote that I realized its because you are searching for 4,000 in regNumArr when you get to 4 * 10 ^3; so youâ€™ll get an error (-1)

As @pjonp says you normally need non-standard symbols for numbers bigger then 3999 (vinculum-based, like XĚ…, or apostrophus-based, like IĆ†). But thereâ€™s no standardised system, itâ€™s all pretty ad-hoc, itâ€™s more sensible to just stop at 3999 as numerals arenâ€™t useful as you get larger numbers: not being able to go above that shouldnâ€™t be an issue

Thanks a lot! I will stop at 3,999 since there is no standardized system for numbers beyond this. I was actually thinking of going to 1 trillion, but Iâ€™ll just keep what I have. Thanks again!