JSFiddle - React, Tailwind, and code Playground

JavaScript

function randString(num, myStr)
    {
        var possible = "*";
        for( var i=0; i < num; i++ ){
            randChar = possible.charAt(Math.floor(Math.random() * possible.length));
            repChar = myStr.charAt(Math.round(Math.random() * myStr.length));
            myStr = myStr.replace(repChar, randChar  );  
        }
        return myStr;
    }

     alert(randString(3, "12345"))