Advertisement
ndburrus

Selecting from many options with Switch Statements @m4sterbu

Aug 10th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // Selecting from many options with Switch Statements
  2. // @m4sterbunny
  3.  
  4. function caseInSwitch(val) {
  5. var answer = "";
  6. // Only change code below this line
  7.  
  8. switch (val) {
  9. case 'a': // the cases are identified in the instructions table. the left column values are the cases (1-4).
  10. answer ="apple";
  11. break;
  12. case b:
  13. answer ="bird";
  14. break;
  15. case "c":
  16. answer ="cat";
  17. break;
  18. default: // a default line in not needed. however, a case 4 is needed.
  19. answer ="stuff"; // not needed.
  20. break;
  21. }
  22. // Only change code above this line
  23. return answer;
  24. }
  25. // Change this value to test
  26. caseInSwitch(1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement