Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var username, password;
  2. var secUser = 'furry';
  3. var secPass = 'yiff';
  4. var successLevel = 0;
  5.  
  6. if(username == secUser) {
  7. successLevel = successLevel + 1; // we add one to our level, so the switch can know we made it to here
  8. }
  9.  
  10. if (password = secPass) {
  11. successLevel = succsesLevel + 2; // we add two here just to be different from the 1
  12. }
  13.  
  14. /* here is the switch statement:
  15.  
  16. if we only had the username correct,
  17. then the succseslevel is 1.
  18.  
  19. if we only have the password correct,
  20. then the successlevel is 2.
  21.  
  22. if both are correct, the level is 3.
  23.  
  24. if neither are correct the level is 0.
  25.  
  26. I put a mistake in the case structure on purpose
  27. so that you will see why the thing I was talking
  28. was needed
  29.  
  30. */
  31.  
  32. switch(successLevel) {
  33. case 0:
  34. // incorrect username and password
  35. case 1:
  36. // incorrect password
  37. break;
  38. case 2:
  39. // incorrect username
  40. break;
  41. default:
  42. // incorrect username and password (this is just to catch for validity sake)
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement