JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test"></div>
JavaScript
function removeRandom(str, amount)
{
for(var i = 0; i < amount; i++)
{
var max = str.length - 1;
var pos = Math.round(Math.random() * max);
str = str.slice(0, pos) + str.slice(pos + 1);
}
return str;
}
document.getElementById("test").textContent = removeRandom("cat123", 3);