Need help converting if / else to JS / Jquery : What I need is to first change the php array to js array:

    $url = "web.com";

    <script type="text/javascript">
    var url = <?php echo json_encode($url); ?>;
    </script>

Now with JS / Jquery I need to do this action:

    if(strpos($url, "com") !== false){
    echo "<p><b style="background-color:blue; color:white;">TEST</b></p>";}
    else{
    echo "<p><b style="background-color:yellow; color:white;">TEST</b></p>";}

How can I do this?