题目:给一个promise,它如果十秒内可以执行出结果就打印出结果,如果十秒内解决不出来就会直接返回失败
let p = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('success')
}, Math.random()*20000)
setTimeout(() => {
reject('fail')
}, 10000)
})
p.then((data) => {
console.log(data)
}).catch(e => console.log(e))