JS Algorithms : Roman Numeral Converter

Tell us what’s happening:
Hi,

With the below code I passed the test. But when I checked the solution it looked quite different.

did I miss out some of the border cases in my code?

**My code **

 function convertToRoman(num) {
    const placeVal = [1,4,5,9,10,40,50,90,100,400,500,900,1000];
    const romNumeral = ['I','IV','V','IX','X','XL','L','XC','C','CD','D','CM','M'];
    var str="";
    // checking value range
    if (num<1 || num>3999){
        console.log ("Not a valid number for conversion");
        return false;
    }
    while (num!==0){ 
        for (let j = 0; j<13; j++){
            while (num>=placeVal[j] && !(j<13 && num>=placeVal[j+1])){
                str+=romNumeral[j];
                num -= placeVal[j];
            }
        }
    }
    num = str;
    return num;
}

convertToRoman(36);

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/roman-numeral-converter

thanks.
I posted a query for the first time, wasn’t aware of this.