var match = "Спартак Москва - Динамо Киев"; 

How to define Dynamo Kiev in this line is played at home or away, that is, whether the front is “-” or not, given that we don’t know the name of the opponent. So then write in the form.

 var match = {teams: "Спартак Москва - Динамо Киев", home: false}; 


    2 answers 2

    Do you want this?

     "Спартак Москва - Динамо Киев".indexOf('Динамо Киев') == 0; 
    • so much easier, thanks - khex
     function home(match) { var n = match.indexOf("Динамо Киев"); if(n==0) return true; else return false; }