I've kind of simplified my code but it looks more or less like this:
<div id = "updatedText"></div>
<script type = "text/javascript">
var rand = 0;
if(var rand == 0)
{
document.getElementById("updatedText").innerText = "short text";
}
else
{
document.getElementById("updatedText").innerText = "much longer text that needs to be rescaled";
}
</script>
Basically the variable rand will change between certain values and based on those values the text will get longer or shorter and I want it to remain in the same fixed area so it should auto re-scale to fit it.