I have an inner function named highchartCheck which does not appear to be executing and I do not know why. The print media query check executes and I get that logged but not the highchartCheck even though I call it at the end of the if block.
if (window.matchMedia) {
    var mq = window.matchMedia('print');
        if (mq.matches) {
            console.log("Print JS Executed");
            function highchartCheck() {
                console.log("check func exec");
                if (document.getElementById('highcharts-0') && document.getElementById("highcharts-2") && document.getElementById("highcharts-4")) {
                    document.getElementById("highcharts-0").querySelectorAll("svg")[0].setAttribute("viewBox", "0 0 5.5in 3.6in");
                    document.getElementById("highcharts-2").querySelectorAll("svg")[0].setAttribute("viewBox", "0 0 5.5in 3.6in");
                    document.getElementById("highcharts-4").querySelectorAll("svg")[0].setAttribute("viewBox", "0 0 5.5in 3.6in");
                    console.log("if exec");
                } else {
                    setTimeout(highchartCheck, 250);
                }
            }
            //Print Styling
            $('#one').find("rect").css({"width": "3.6in !important";});
            $('#two').find("rect").css({"width": "3.6in !important";});
            $('#three').find("rect").css({"width": "3.6in !important";});
            highchartCheck();
        }
}
 
    