Tuesday, October 02, 2007

function domainCheck(url:String, domain:String) {
return url.indexOf(domain) != -1;
}

What's wrong with the above code, which attempts to check if url contains domain?


Answer: if url is undefined, indexOf returns undefined instead of -1.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home