const enoughToReadArticle = 1500
function test(userLikedTheArticle) {
const promiseToReader = new Promise((resolve, reject) => {
setTimeout(function() {
if (userLikedTheArticle) {
resolve('This article is awesome!')
} else {
reject('I should have never been here! ;p')
}
}, enoughToReadArticle)
})
promiseToReader.then(result => {
console.log('result', result)
}, error => {
console.error('error in then', error)
})
promiseToReader.catch(error => {
console.error('error', error)
})
}
console.log('Initiating test...')
console.log('Good reader started reading...')
test(true)
console.log('Probably what is a bot started reading...')
test(false)
console.log('Both users are now reading, and soon I should get my results')
This Pen doesn't use any external CSS resources.