JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = "cat123";
var strArray = str.split("");

function getRandomizer(bottom, top) {
        return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom;
    }
alert("Total length " + strArray.length);
var nrand = getRandomizer(1, strArray.length);
alert("Randon number between range 1 - length of string " + nrand);

alert("Character @ random position " + strArray[nrand]);