Last active
July 27, 2017 13:33
-
-
Save stewones/1fc21c27d339d5d3f947092d53bca401 to your computer and use it in GitHub Desktop.
search sda 17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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