Problem in roman numeral converter challenge

There is a problem in running tests in roman numeral converter challenge for front-end development certification.
This is my code:


function convertToRoman(num) {
  num = num.toString();
 var multiplier = 1;
 var arr = num.split('');
  arr.reverse();
  
  for (i=0;i<arr.length;i++){
    var digit = arr[i] * multiplier;
    arr[i] = toRoman(digit);
    multiplier *= 10;
  }
  
  arr.reverse();
  return arr.join('');
}

function toRoman(num) {
  switch (num) {
    case 1: return 'I';
    case 2: return 'II';
    case 3: return 'III';
    case 4: return 'IV';
    case 5: return 'V';
    case 6: return 'VI';
    case 7: return 'VII';
    case 8: return 'VIII';
    case 9: return 'IX';
    case 10: return 'X';
    case 20: return 'XX';
    case 30: return 'XXX';
    case 40: return 'XL';
    case 50: return 'L';
    case 60: return 'LX';
    case 70: return 'LXX';
    case 80: return 'LXXX';
    case 90: return 'XC';
    case 100: return 'C';
    case 200: return 'CC';
    case 300: return 'CCC';
    case 400: return 'CD';
    case 500: return 'D';
    case 600: return 'DC';
    case 700: return 'DCC';
    case 800: return 'DCCC';
    case 900: return 'CM';
    case 1000: return 'M';
    case 2000: return 'MM';
    case 3000: return 'MM';
    case 4000: return 'MMMM';
  }
}

convertToRoman(3999);

When i run this code in freecodecamp, It passes all the tests except 3999. But, when i run this code in my console, it shows correct roman numerals for 3999. I had attached the screenshot of freecodecamp test below.
1