Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. const doSomething = () => {}
  2. const doSomethingElse = () => {}
  3. const doMagic = () => {}
  4. let cases = {
  5. 'a': doSomething,
  6. 'b': doSomethingElse,
  7. 'c': doMagic
  8. };
  9. let key = ???;
  10. if (containsKey(cases, key)) {
  11. cases[key]();
  12. } else {
  13. console.log("I don't know what to do!");
  14. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement