Created
October 17, 2011 18:01
-
-
Save mrandyclark/1293303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// this is a function that you're going to pass a messageCode to. | |
// the message code will be an integer and you'll return a string | |
// that is the error message. | |
function getErrorMessage(messageCode) | |
{ | |
var errorMessage = ""; | |
if(messageCode == 1) | |
errorMessage = "Your username could not be found." | |
} else if(messageCode == 2) { | |
errorMessage = "Your password is incorrect." | |
} else if(messageCode == 3) { | |
errorMessage = "You are just an idiot." | |
} | |
return errorMessage; | |
} | |
// writes the 1st error message | |
document.write( getErrorMessage(1) ); | |
// writes the 2nd error message | |
document.write( getErrorMessage(2) ); | |
// writes the 3rd error message | |
document.write( getErrorMessage(3) ); | |
// writes no error message | |
document.write( getErrorMessage(4) ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment