# Roman numerals solution works elsewhere, but not on FCC console

Hello,

Below is my initial solution to the roman numerals question.
I know it is not at all elegant and has lots of hard-coding. That is for later to improve.

But for now it works perfectly on my browser console and also on repl.it, passing all the tests. Only on FCC’s console none of the tests pass.

Anyone know why?

``````var answer = "";
function convertToRoman(num) {
var baseArray = numToArray(num);
thousands(baseArray[0]);
hundreds(baseArray[1]);
tens(baseArray[2]);
units(baseArray[3]);
}
convertToRoman(12);

function numToArray(num){
var stringIt = num.toString();
var arr0 = [];
for(var i = 4, j = 1; i > 0; i--, j++){
arr0[i-1] = stringIt.charAt(stringIt.length - j);
}
return arr0;
}

function thousands(num){
var thou = "";
if(num !== "" && num !== 0){
for(var i = 0; i < num; i++){
thou += "M";
}
}
}

function hundreds(num){
var hun = "";
if(num !== "" && num !== 0){
switch (num){
case "1":
case "2":
case "3":
for(var i = 0; i < num; i++){
hun += "C";
}
break;
case "4":
hun = "CD";
break;
case "5":
hun = "D";
break;
case "6":
hun = "DC";
break;
case "7":
hun = "DCC";
break;
case "8":
hun = "DCCC";
break;
case "9":
hun = "CM";
break;
}
}
}

function tens(num){
var tens = "";
if(num !== "" && num !== 0){
switch (num){
case "1":
case "2":
case "3":
for(var i = 0; i < num; i++){
tens += "X";
}
break;
case "4":
tens = "XL";
break;
case "5":
tens = "L";
break;
case "6":
tens = "LX";
break;
case "7":
tens = "LXX";
break;
case "8":
tens = "LXXX";
break;
case "9":
tens = "XC";
break;
}
}
}

function units(num){
var tens = "";
if(num !== "" && num !== 0){
switch (num){
case "1":
case "2":
case "3":
for(var i = 0; i < num; i++){
tens += "I";
}
break;
case "4":
tens = "IV";
break;
case "5":
tens = "V";
break;
case "6":
tens = "VI";
break;
case "7":
tens = "VII";
break;
case "8":
tens = "VIII";
break;
case "9":
tens = "IX";
break;
}