I am learning JavaScript and I am stuck on this particular error for a long time now. It's nothing complicated, but I can't figure it out. The error I get is:
ReferenceError: Random is not defined
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));
is a variablerandom
variable and assign a value to it.Pass 'Random' or "Random" as parameter which will take it as a string.
nameString(Random) -> Random acts as an object
nameString("Random") -> Random acts as a string
You have to write.
nameString(Random) -> Random acts as an object nameString("Random") -> Random acts as a string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.