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.

No comments:

Post a Comment