Quick question on Roman Numeral Converter

How can I get back [“I”][“I”][“I”] instead of [“I”] when I use return. Why does the console give me what I want and not the return ? Thank you for your time. I know return exits the function but why can’t I seem to return I 3 times. The only way I can do it is through console.log(numOne) in my console it returns [“I”][“I”][“I”] but how do I implement that using return without it returning just [“I”]

   **Your code so far**
function convertToRoman(num) {
 let numOne = ["I"]
for(let i=1; i<=num; i++){
 console.log(numOne)
  
}

}

console.log(convertToRoman(3));
   **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:

return immediately exits the function call

1 Like

You could put the [‘I’]'s in a variable of some sort after doing your loop, then return that variable.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.