[英]ReferenceError: ____ is not defined
I am learning JavaScript and I am stuck on this particular error for a long time now.我正在学习JavaScript ,并且很长时间以来一直被这个错误所困扰。 It's nothing complicated, but I can't figure it out.这没什么复杂的,但我无法弄清楚。 The error I get is:我得到的错误是:
ReferenceError: Random is not defined ReferenceError:随机未定义
My Code:我的代码:
var nameString = function(name)
{
return "Hi, I am " + name;
};
console.log(nameString(Random));
The objective of the code is basically to show "My name is Random" on the screen.代码的目的基本上是在屏幕上显示“我的名字是随机的”。
What am I doing wrong?我究竟做错了什么? Please help :)请帮忙 :)
random
which you are passing while calling that console.log(nameString(Random));
您在调用该console.log(nameString(Random));
时传递的random
数; is a variable是一个变量random
variable and assign a value to it.因此,要么用引号将其作为字符串传递,要么声明random
变量并为其赋值。Pass 'Random' or "Random" as parameter which will take it as a string.传递“随机”或“随机”作为参数,将其作为字符串。
nameString(Random) -> Random acts as an object nameString(Random) -> Random 充当对象
nameString("Random") -> Random acts as a string nameString("Random") -> Random 充当字符串
You have to write.你必须写。
nameString(Random) -> Random acts as an object nameString("Random") -> Random acts as a string
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.