Why won't my Roman Number Conversion work?

All my tests return the correct number. Why won’t it work?

var numArr = {
  '1':['I', 'X', 'C', 'M'], 
  '2':['II', 'XX', 'CC', 'MM'], 
  '3':['III', 'XXX', 'CCC', 'MMM'], 
  '4':['IV', 'XL', 'CD', 'MV'],
  '5':['V', 'L', 'D', 'V'],
  '6':['VI', 'LX', 'DC', 'VM'],
  '7':['VII', 'LXX', 'DCC', 'VMM'],
  '8':['VIII', 'LXXX', 'DCCC', 'VMMM'],
  '9':['IX', 'XC', 'CM', 'MX']
	newNum =[];

function convertToRoman(num) {
  var res = num.toString().split("");
  for (var i = res.length - 1; i >= 0; i--) {
  newNum = newNum.join('');
  return newNum;


It’s because you’re declaring the newNum variable in the global namespace. Try moving your variables inside your function,so they’re not available outside of its scope and check if it passes the tests.

Right on spot! Thanks a lot.