delta one handle kitchen faucets

String Compare Function

The compare function allows the coder to determine if two strings are the same.

 

Below we have created a fake authentication system and use an if statement to see if the user’s name will grant them access to a special message.

Example: <script type=”text/javascript”>

var name = “Roger Rabbit”;

if(name == “Jessica Rabbit”)

document.write(“Hello Beautiful!”);

else

document.write(“Go away!”);

document.write(“<Try again?”);

 

// User enters a different name

name = “Jessica Rabbit”;

if(username == “Jessica Rabbit”)

document.write(“Hello Beautiful!”);

else

document.write(“Access Denied!”);

 

</script>

 

Display: Go away!

Try again?

Hello Beautiful!

Loading... Next Page »