Replacing entire tag with shortcode – JavaScript [duplicate]

This looks like javascript. do_shortcode is a php function. I’m not sure the full context, but at the very least, you need to wrap your php function in php tags like this and add an echo:

<?php // Start of php file ?>
<script>
    var stockcounter = document.getElementsByClassName("stock in-stock");

    if(stockcounter[0].innerHTML=='0 in stock') {
        //Displays timer
        stockcounter[0].outerHTML = "<?php echo do_shortcode('[fergcorp_cdt_single date="Feb 25 2019 18:45:00"]'); ?>";
    }
</script>

I’m assuming this script is within a php file.