Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const _ = require('lodash');
- var games = [{
- name: 'Street Fighter',
- year: 1990
- },
- {
- name: 'Top Gear',
- year: 1992
- },
- {
- name: 'Mortal Kombat',
- year: 1991
- },
- {
- name: 'Abcx',
- year: 2019
- }
- ]
- function sGame(a) {
- return new Promise((resolve, reject) => {
- console.log('Searching...');
- setTimeout(() => {
- if (_.find(games, (o) => {
- resolve(o.name == a);
- })) {
- console.log('The game ' + a + ' was found on the list!');
- } else {
- console.log('The game ' + a + ' was not found on the list!');
- }
- }, 3 * 1000);
- });
- }
- sGame('Mortal Kombat');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement