These are the task that I need to do and what i have done so far with no success, please help if you can ?
this is the task – returns an array of urls from pages for which the corresponding content matches pattern (in the style of function 3)
what I’ve done but doesn’t work – function urls(pages,pattern)
{
var pages=pattern.toUpperCase();
var pattern=pattern.toUpperCase();
for(var k=0;k<pattern.length;k++)
{
if(string.indexOf(pattern[k])<0)
return false;
}
return true;
}
the task – returns an array of records of the form {url: … , score: … } derived from web. Each record contains a url and the pattern score of its corresponding content.
Records with a score of zero are omit
what I’ve done but doesn’t work – function urlScores(web,pattern){
var result=[];
var record={};
for(i=0;i<web.length;i++){
var index=-1;
result[i]=0;
do{
index=web[i].url.toLowerCase().indexOf(pattern.toLowerCase()); index+1;
if(index>=0){
result[i]=result[i]+1;
record.url=web[i].url;
record.content=result[i];
}
}while (index>=0)
}
return record.url+””+record.content;
}
please help if you can, many thanks ?