Skip to content

Instantly share code, notes, and snippets.

@stewones
Last active July 27, 2017 13:33
Show Gist options
  • Save stewones/1fc21c27d339d5d3f947092d53bca401 to your computer and use it in GitHub Desktop.
Save stewones/1fc21c27d339d5d3f947092d53bca401 to your computer and use it in GitHub Desktop.
search sda 17
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(() => {
let result = _.find(games, (o) => {
return (o.name == a);
});
if (result) {
console.log('The game ' + a + ' was found on the list!');
resolve(result)
} else {
console.log('The game ' + a + ' was not found on the list!');
reject();
}
}, 3 * 1000);
});
}
sGame('Mortal Kombat');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment