function 猜大小 (猜想) {return new Promise((resolve, reject) => {// 背下来 console.log("开始摇色子");
setTimeout(() => {let n = 6; //parseInt(Math.random() * 6 + 1, 10); // 1~6 if (n > 3) {if ( 猜想 === "大") {resolve(n);
} else {reject(n);
}
} else {if ( 猜想 === "小") {resolve(n);
} else {reject(n);
}
}
}, 1000);
});
}
async function test() {
try {let n /*[6,6]*/ = await Promise.all([猜大小 ("大"), 猜大小 ("大")]);
console.log("好嗨哦" + n);
} catch (error) {console.log("输光了" + error);
}
}
var result = test();
console.log(result);