Tell us what’s happening:
Describe your issue in detail here.
No clue what the issue is. The tests should be passed in my opinion.
**Your code so far**
let strAns = "";
function romanConv (num, place, placeCheck = 0) {
let initStr = "";
let additionalStr = "";
let i = 0;
if (place == 'thousands'){
placeCheck = num.toString().length - 4;
}
else if (place == 'hundreds'){
placeCheck = num.toString().length - 3;
}
else if (place == 'tens'){
placeCheck = num.toString().length - 2;
}
else if (place == 'ones'){
placeCheck = num.toString().length - 1;
}
if (place == 'thousands' && num.toString()[placeCheck] >= 5){
initStr = "MXbar|Vbar";
additionalStr = "M";
}
else if (place == 'thousands' && num.toString()[placeCheck] < 5){
initStr = "MVbar|M";
additionalStr = "M";
}
if (place == 'hundreds' && num.toString()[placeCheck] >= 5){
initStr = "CM|D";
additionalStr = "C";
}
else if (place == 'hundreds' && num.toString()[placeCheck] < 5){
initStr = "CD|C";
additionalStr = "C";
}
if (place == 'tens' && num.toString()[placeCheck] >= 5){
initStr = "XC|L";
additionalStr = "X";
}
else if (place == 'tens' && num.toString()[placeCheck] < 5){
initStr = "XL|X";
additionalStr = "X";
}
if (place == 'ones' && num.toString()[placeCheck] >= 5){
initStr = "IX|V";
additionalStr = "I";
}
else if (place == 'ones' && num.toString()[placeCheck] < 5){
initStr = "IV|I";
additionalStr = "I";
}
if(num.toString()[placeCheck] == 4 | num.toString()[placeCheck] == 9){
strAns += initStr.split('|')[0]
}
else if (num.toString()[placeCheck] == 5){
strAns += initStr.split('|')[1]
}
else if (num.toString()[placeCheck] > 5){
for (i = 0; i < num.toString()[placeCheck] - 5 + 1; i++){
if(i == 0){
strAns += initStr.split('|')[1]
}
else{
strAns += additionalStr
}
}
}
else if (num.toString()[placeCheck] >= 1 && num.toString()[placeCheck] <= 3){
for (i = 0; i < num.toString()[placeCheck] ; i++){
strAns += additionalStr
}
}
}
function convertToRoman(num) {
let one = "I";
let five = "V";
let ten = "X";
let fifty = "L";
let hundred = "C";
let fivehundred = "D";
let thousand = "M"
let i = 0;
let place = "";
let placeCheck = 0;
//let strAns = "";
//console.log(num)
for (i = num.toString().length; i > 0; i--){
if(i == 4){
place = 'thousands'
}
else if (i == 3){
place = 'hundreds'
}
else if (i == 2){
place = 'tens'
}
else if (i == 1){
place = 'ones'
}
romanConv(num, place, placeCheck)
//finAns += strAns;
}
//console.log(strAns)
let finAns = "";
finAns = strAns.toUpperCase().trim();
num === finAns;
return num;
}
convertToRoman(36);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36
Challenge: Roman Numeral Converter
Link to the challenge: