编辑代码

async function getStockSymbol(name) {
    console.log(await 111);
    console.log(await 111);
    console.log(await 111);
    console.log(await 111);
    console.log(await 111);
    return "111" + name;
}
async function getStockPrice(symbol) {
    console.log(await 222);
    console.log(await 222);
    console.log(await 222);
    console.log(await 222);
    console.log(await 222);
    return "222" + symbol;
}
async function getStockPriceByName(name) {
    const symbol = await getStockSymbol(name);//等待getStockSymbol执行完
    const stockPrice = await getStockPrice(symbol);//等待getStockPrice执行完
    return stockPrice;
}
function bb() {
    //await getStockPriceByName('goog').then(console.log);
    //await 会等待异步执行完 才继续执行
    //如果不加 await getStockPriceByName就是异步执行
    getStockPriceByName('goog').then(console.log);
    console.log(3333);
}
bb();