Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. //Program With Erik
  2.  
  3. const games = ['legend', 'pokemon', 'fortnite', 'blah']
  4.  
  5.  
  6. games.forEach(val=> {
  7.  
  8. if(val === 'legend'){
  9. console.log('legends')
  10. } else if(val === 'pokemon') {
  11. console.log('poke')
  12. } else {
  13. console.log('default')
  14. }
  15.  
  16. switch(val){
  17. case 'legend':
  18. console.log('legends')
  19. break;
  20. default:
  21. console.log('test')
  22. break;
  23.  
  24. }
  25.  
  26.  
  27. const getGame= game => {
  28. const itsALegend = _ =>{
  29. return 'this is a legend'
  30. }
  31. const itsAPokemon = _ => {
  32. return 'this is pokemon'
  33. }
  34. const games = {
  35. legend: itsALegend,
  36. pokemon: itsAPokemon,
  37. default: _=> {
  38. return 'unknown'
  39. }
  40. }
  41.  
  42. return (games[game] || games.default)()
  43. }
  44.  
  45. console.log(getGame(val))
  46.  
  47.  
  48. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement