Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program With Erik
- const games = ['legend', 'pokemon', 'fortnite', 'blah']
- games.forEach(val=> {
- if(val === 'legend'){
- console.log('legends')
- } else if(val === 'pokemon') {
- console.log('poke')
- } else {
- console.log('default')
- }
- switch(val){
- case 'legend':
- console.log('legends')
- break;
- default:
- console.log('test')
- break;
- }
- const getGame= game => {
- const itsALegend = _ =>{
- return 'this is a legend'
- }
- const itsAPokemon = _ => {
- return 'this is pokemon'
- }
- const games = {
- legend: itsALegend,
- pokemon: itsAPokemon,
- default: _=> {
- return 'unknown'
- }
- }
- return (games[game] || games.default)()
- }
- console.log(getGame(val))
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement