声明变量后我可以使用tolowercase()吗? [英] Can I use tolowercase() after declaring a variable?
本文介绍了声明变量后我可以使用tolowercase()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(文件名为:test.js)
问题在于:
(THE FILE NAME IS: test.js)
Here is the problem:
var Hardware = prompt("What are the physical components of the computer, such as the moniter and system unit, called?");
if (Hardware.toLowercase() == "hardware") {
var number = 1;
} else { alert("You have failed the test. Please refresh."); }
if (number == 1) {
}
现在,问题是我每次运行时都会遇到一个typeError,它表示:
Now, the problem is that I get a typeError whenever I run this, which states:
引用:
未捕获TypeError:Hardware.toLowercase不是函数
at test.js:2
Uncaught TypeError: Hardware.toLowercase is not a function
at test.js:2
我尝试了什么:
我试过看看其他人是否有这个同样的问题;我认为没有人。
What I have tried:
I have tried looking to see if others have had this same problem; I don't think anyone has.
推荐答案
它应该是
toLowerCase()
注意区分大小写。
Javascript区分大小写。我修复了你的代码,现在就检查一下。
Hi, Javascript is case sensitive. I've fixed your code, check it now.
var Hardware = prompt("What are the physical components of the computer, such as the moniter and system unit, called?");
alert(Hardware);
if (Hardware.toLowerCase() == "hardware") {
var number = 1;
} else { alert("You have failed the test. Please refresh."); }
if (number == 1) {
alert ("Hello I love to be 1")
}
Happy Coding!
Happy Coding!
这篇关于声明变量后我可以使用tolowercase()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文