Hey, I was working on this but I'm kinda stuck. Can someone help me out please?

This is the initial question:

Name of function and its parameter
urls(pages,pattern)

Description
returns an array of urls from pages for which the corresponding content matches pattern

I worked out a code but it crashed somewhere

Code:
function urlpart(s)
{
    //function to find seperator 
    var seperator = s[0];
    var seperatorfind = s.lastIndexOf(seperator);
 //   var endofurl = s.charAt(s.length);
    
    var theurl = s.substring(1,seperatorfind);
        
    
    return theurl;
} 

var pages = [ "|www.liv.ac.uk|Liverpool University offers degree programmes and world class research.", "!www.xyz.ac.uk!An alternative University" , "%www%Yet another University" ];

function urls(pages,pattern); {

var matchurls= [];

for (var i=0;i< pages.length;i++)
{

if(match(content(pages[i],pattern)));

matchurls[matchurls.length]= pages[i];


return matchurls;  
}
else 
 return " " ;

}

alert(urls(pages,"an"));
alert(urls(pages,"un"));
I don't think it is correct so I'm trying to change the format and make the code smaller. A little advice will be appreciated!