quick question this while loop.
while(myNum[myNum.length-1] >5 && myNum[myNum.length-1] <9){
myNum[myNum.length-1] = numToRoman[5]} why is it returning undefined?
**Your code so far**
function convertToRoman(num) {
let myArr = [];
let myNum = num.toString().split("").map(Number)
let numToRoman ={1:"I", 2:"II", 3:"III", 4:"IV",5:"V",9:"IX", 10:"X",40:"XL",50:"L",90:"XC",100:"C",400:"CD",500:"D",900:"CM", 1000:"M"}
for(let i=0; i<myNum.length; i++){
if(myNum.length === 2){
return numToRoman[10] +numToRoman[myNum[1]]
}
}
while(myNum[myNum.length-1] >5 && myNum[myNum.length-1] <9){
myNum[myNum.length-1] = numToRoman[5]}
}
console.log(convertToRoman(17));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
Challenge: Roman Numeral Converter
Link to the challenge: