Wednesday, November 12, 2008

JavaScript Substring

JavaScript Code:


var username = "someAgent";
if(username == "SomeAgent")
document.write("Welcome special agent");
else
document.write("Access Denied!");

// Now as case insensitive
document.write("

Let's try it with toLowerCase

");
if(username.toLowerCase() == "SomeAgent".toLowerCase())
document.write("Welcome special agent");
else
document.write("Access Denied!");



Display:
Access Denied!

Let's try it with toLowerCase

Welcome special agent

No comments: