Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var username, password;
- var secUser = 'furry';
- var secPass = 'yiff';
- var successLevel = 0;
- if(username == secUser) {
- successLevel = successLevel + 1; // we add one to our level, so the switch can know we made it to here
- }
- if (password = secPass) {
- successLevel = succsesLevel + 2; // we add two here just to be different from the 1
- }
- /* here is the switch statement:
- if we only had the username correct,
- then the succseslevel is 1.
- if we only have the password correct,
- then the successlevel is 2.
- if both are correct, the level is 3.
- if neither are correct the level is 0.
- I put a mistake in the case structure on purpose
- so that you will see why the thing I was talking
- was needed
- */
- switch(successLevel) {
- case 0:
- // incorrect username and password
- case 1:
- // incorrect password
- break;
- case 2:
- // incorrect username
- break;
- default:
- // incorrect username and password (this is just to catch for validity sake)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement