我正在codecademy上学习 javascript 。以下程序在我提交时卡住了。我是新手,所以我找不到错误。我下载了Aptana Studio,但我不知道如何调试:(。有什么方法可以跟踪代码吗?提前谢谢。
var slaying = true;
var youHit = Math.random() > 0.5;
var damageThisRound = Math.floor(5 * Math.random());
var totalDamage = 0;
while (slaying) {
if (youHit) {
console.log("You hit the dragon.");
totalDamage += damageThisRound;
if (totalDamage >= 4) {
console.log("You've stew the dragon!");
slaying = false;
} else {
youHit = Math.random() > 0.5;
}
} else {
console.log("The dragon defeated you.")
}
}