是的,这是家庭作业。我完成了任务。只需要在玩家完成游戏并获胜时制作警告框。
如果用户点击“确定”,则确认框将消失,并显示一个新的随机板,就好像点击了“开始新游戏”一样。
如果用户点击“取消”,则确认框将消失,并且显示将保留在获胜位置的图块,与最初加载页面时相同。用户可以点击“开始新游戏”以开始新游戏。
链接到实际作业:http://www.eveo.org/tiles/ver2
JAVASCRIPT文件链接:http://www.eveo.org/tiles/ver2/game.js
我不打算改变其他任何东西,只需修复此警报框问题。到目前为止,我(伪代码):
if win = true
confirm box ("You won! Congratulations! Would you like another game?")
upon pressing OK: board randomized
upon cancel: nothing happens, used needs to click "start a new game"
答案 0 :(得分:1)
break
仅适用于switch
,for
和while
个结构。不要把它放在其他地方。如果您不想在else
上执行任何操作,请将其留空或完全删除。
if (confirm("You won! Congratulations! Would you like another game?")) {
initialize();
}
答案 1 :(得分:0)
var confirmer = confirm("Wish to accept or Cancel?");
if(confirmer){
// Do stuff on OK
initialize();
}else{
// Do other stuff on cancel
}
答案 2 :(得分:0)
据我所知,你几乎那里:
if (confirm("Wish to accept or Cancel")) {
if (confirm(("You won! Congratulations! Would you like another game?")) {
initialize();
}
}