let runPromiss = (name, time, status) => {
  return new Promise((resolve, reject) => {
    if(status) {
      console.log(`${name} 起跑了!`)
      return setTimeout(() => {
		    resolve(`${name} 衝了 ${time / 1000}秒`)
      },time);
    } else {
     reject(new Error(`${name} 出現錯誤`));
    };
  });
};
// 小明失敗,就回傳錯誤訊息

let asyncPromise = async function() {
  let min = await runPromiss('小明', 3000, false);
  let wei = await runPromiss('小王', 1000, true);
  return `${min},${wei}`;
}
asyncPromise().then((res)=>{
  console.log(res)
}).catch((error) => {
  console.log(error);
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.