我的自我教育进展缓慢,我遇到了问题。我试图从用户那里获得文本输入。然后,我希望该输入是针对自身的大写版本进行检查的。我通过labs.codecademy.com运行代码(如果这是相关的)。string.toUpperCase困难
代码:
function rollerInput() {
var input = prompt("Do you want to reroll? You have " + rerolls + " rerolls left. Y/N?");
input = input.toUpperCase;
if(input === null) {
console.log("Please enter Y or N");
rollerInput();
} else if(input === "") {
console.log("Please enter Y or N");
rollerInput();
} else if(input === "Y" && rerolls !== 1) {
rerolls = rerolls -1;
reRoller();
} else if(input === "Y" && rerolls === 1) {
console.log("You have no rerolls left.");
}
}
问题在于与检查Y或N.无论ÿ或y产生任何反应的IFS。我确信我错过了一些简单的东西,但我无法修复它以挽救我的生命。
这是一个方法,你必须用括号把它称为'()':'输入= input.toUpperCase();' – vikingmaster 2014-09-22 21:00:55
@GregHewgill&SterlingArcher的感谢!我的错。 – 2014-09-22 22:16:42