<分区>
在下面的脚本中,我在 if
语句的 else if
部分使用了 ternary
语句,将两者并列。在这种情况下,我是否应该在 else if
中替换另一个 if
语句?
var attackOpt = prompt('Which attack option does Angelo use in this turn?');
// Remaining number of times Angelo can cast spells:
var angMP = 3;
// Validity Check to see if the attack option entered can be executed:
while (true) {
if (attackOpt === 'slash') {
break;
}
else if (attackOpt === 'magic') {
(angMP) ?
break;
: attackOpt = prompt('Angelo can no longer cast spells. Select again.');
}
}