2020年7月4日 星期六

Chore Door!

gameOver('win') 

const gameOver = (status) => {
    if (status === 'win' ){
        startButton.inner = 'Good luck!' ;
    }
}

以上無法 hoisting,跑不出結果。

但是  gameOver('win') 是包覆在其他 "函數體內"是OKay的。

_________________________________________________

const numClosedDoors = 3;    <------改成 let numClosedDoors = 3;

const playDoor = ( ) => {
    numClosedDoors --;    <--------------- const numClosedDoors 常數無法 --
    if (numClosedDoors === 0) {
        gameOver('win')
    }
}




沒有留言:

張貼留言