function formatRoman(value, pattern) {
  let i,
    s = '',
    v = Number(String(value).slice(-3)),
    nThousands = (value - v) / 1000,
    decimal = [0, 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900].reverse(),
    numeral = ['0', 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM'].reverse();

  while (v > 0) {
    for (i = 0; i < decimal.length; i++) {
      if (decimal[i] <= v) {
        s += numeral[i];
        v -= decimal[i];
        break;
      }
    }
  }

  for (i = 0; i < nThousands; i++) {
    s = `M${s}`;
  }

  if (pattern[1] !== pattern[1].toUpperCase()) {
    s = s.toLowerCase();
  }
  return s;
}
// value must not be in scientific notation
value must not be in scientific notation
value must not be in scientific notation
function formatRoman(value, pattern) {
  let i,
    s = '',
    v = Number(String(value).slice(-3)),
    nThousands = (value - v) / 1000,
    decimal = [0, 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900].reverse(),
    numeral = ['0', 'I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM'].reverse();
  while (v > 0) {
    for (i = 0; i < decimal.length; i++) {
      if (decimal[i] <= v) {
        s += numeral[i];
        v -= decimal[i];
        break;
      }
    }
  }
  for (i = 0; i < nThousands; i++) {
    s = `M${s}`;
  }
  if (pattern[1] !== pattern[1].toUpperCase()) {
    s = s.toLowerCase();
  }
  return s;
}
function formatRoman ( value , pattern ) { let i , s = '' , v = Number ( String ( value ) . slice ( - 3 ) ) , nThousands = ( value - v ) / 1000 , decimal = [ 0 , 1 , 4 , 5 , 9 , 10 , 40 , 50 , 90 , 100 , 400 , 500 , 900 ] . reverse ( ) , numeral = [ '0' , 'I' , 'IV' , 'V' , 'IX' , 'X' , 'XL' , 'L' , 'XC' , 'C' , 'CD' , 'D' , 'CM' ] . reverse ( ) ; while ( v > 0 ) { for ( i = 0 ; i < decimal . length ; i ++ ) { if ( decimal [ i ] <= v ) { s += numeral [ i ] ; v -= decimal [ i ] ; break ; } } } for ( i = 0 ; i < nThousands ; i ++ ) { s = ` ${ s } ` ; } if ( pattern [ 1 ] !== pattern [ 1 ] . toUpperCase ( ) ) { s = s . toLowerCase ( ) ; } return s ; }
value must not be in scientific notation
value must not be in scientific notation