Why doesn't my recursive call return anything?

I am on the Roman Numeral Challenge and am having a problem figuring something out. So when i try to call my converttoRoman function recursively within itself around line 100 where i call convertToRoman(remaindertrack) it will not return anything to the code testing thing on the left (don’t know what that is called). But when i post it to a javascript visualizer online it showing that the return value of 102 is CII, what is going on here? Any help would be much appreciated. Also it keeps saying it failed all the tests even though i know for a fact it works up to 10.

	var returnRoman = ''; // to store return roman numerals
	var remaindertrack = ''; // to keep track of modulus remainders later on

	function romanDict(num) {
	  var newnum = num;
	  switch(num) {
		case 1:
		  num = "I";
		  break;
		case 2:
		  num = "II";
		  break;
		case 3:
		  num = "III";
		  break;
		case 4:
		  num = "IV";
		  break;
		case 5:
		  num = "V";
		  break;
		case 6:
		  num = "VI";
		  break;
		case 7: 
		  num = "VII";
		  break;
		case 8:
		  num = "VIII";
		  break;
		case 9:
		  num = "IX";
		  break;
		case 10:
		  num = "X";
		  break;
		case 20:
		  num = "XX";
		  break;
		  case 30:
		  num = "XXX";
		  break;
		  case 40:
		  num = "XL";
		  break;
		  case 50:
		  num = "L";
		  break;
		  case 60:
		  num = "LX";
		  break;
		  case 70:
		  num = "LXX";
		  break;
		  case 80:
		  num = "LXXX";
		  break;
		  case 90:
		  num = "XC";
		  break;
		  case 100:
		  num = "C";
		  break;
		case 200:
		  num = "CC";
		  break;
		  case 300:
		  num = "CCC";
		  break;
		  case 400:
		  num = "CD";
		  break;
		  case 500:
		  num = "D";
		  break;
		  case 600:
		  num = "DC";
		  break;
		  case 700:
		  num = "DCC";
		  break;
		  case 800:
		  num = "DCCC";
		  break;
		  case 900:
		  num = "CM";
		  break; 
		  case 1000:
		  num = "M";
		  break; 
		default:
		  num = "please input a valid number";
	  }
	  
	  return num;
	}


	function convertToRoman(num) {
	  if(num <= 10) {
		returnRoman += romanDict(num);
		return(returnRoman);
	  }
	  
	  else if (num >= 100 && num % 100 === 0) {
		returnRoman += romanDict(num);
		return(returnRoman);
	  }
	  
	  else if (num >= 100 && num % 100 !== 0) {
		remaindertrack = num  % 100;
		num -= remaindertrack;
		returnRoman +=  romanDict(num);  
		convertToRoman(remaindertrack);
	  }
	  
	  else if(num > 10 && num % 10 === 0) {
		return (romanDict(num));
	  }
	  
	  else if (num > 10 && num % 10 !== 0) {
		remaindertrack = num % 10;
		num -= remaindertrack;
		returnRoman += romanDict(num) + romanDict(remaindertrack);
		return(returnRoman);
	  }
	  
	}

	convertToRoman(102);

Hey, I figured it out. I posted the answer here. https://www.diffschool.com/questions/why-doesn-t-my-recursive-call-return-anything

1 Like

thanks but now they still aren’t passing any of the tests on the left for some reason, i keep getting X’s for all of them even though a bunch of them should still pass.

Have you tried refreshing the page? remember to copy your answer. Btw I am creating online study groups if you are interested. http://forum.freecodecamp.com/t/online-study-group-for-different-time-zones/49226

thats a great idea! am checking out now

signed up thanks again btw

Hey, I figured out why it doesn’t pass, there is a small issue with where you place your variables. I posted the answer here https://www.diffschool.com/questions/why-doesn-t-my-recursive-call-return-anything