Advertisement
Guest User

Dia 1 - Exercicio Aula 2

a guest
Jul 26th, 2017
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const _ = require('lodash');
  2.  
  3. var games = [{
  4.         name: 'Street Fighter',
  5.         year: 1990
  6.     },
  7.  
  8.     {
  9.         name: 'Top Gear',
  10.         year: 1992
  11.     },
  12.  
  13.     {
  14.         name: 'Mortal Kombat',
  15.         year: 1991
  16.     },
  17.  
  18.     {
  19.         name: 'Abcx',
  20.         year: 2019
  21.     }
  22. ]
  23.  
  24. function sGame(a) {
  25.     return new Promise((resolve, reject) => {
  26.         console.log('Searching...');
  27.         setTimeout(() => {
  28.             if (_.find(games, (o) => {
  29.                     resolve(o.name == a);
  30.                 })) {
  31.                 console.log('The game ' + a + ' was found on the list!');
  32.             } else {
  33.                 console.log('The game ' + a + ' was not found on the list!');
  34.             }
  35.         }, 3 * 1000);
  36.     });
  37. }
  38.  
  39. sGame('Mortal Kombat');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement