Everytime I run the script, it says:
party is undefined
Here's what I got:
party()
var party = function (name){
alert("You must find your way into the party and kill the VIP")
};
It won't run on any js website. What should I do?
-
While a human might be able to understand "Do the thing. The thing is to...", a computer is more logical than that. You must tell it "The thing is to... Now, do the thing"Niet the Dark Absol– Niet the Dark Absol2015年02月11日 02:14:42 +00:00Commented Feb 11, 2015 at 2:14
4 Answers 4
you must define your function before using it.
Comments
It's either what @user148098 has suggested OR:
party()
function party(){
alert("You must find your way into the party and kill the VIP")};
where you define a function explicitly.
Comments
You called party() before you defined it in var party = function (na...
Just define it first and than call it, like this:
var party = function (name) {alert("You must find your way into the party and kill the VIP")};
party()
Comments
The problem might be because you need to define a function before you call it. Here is an example:
var party = function (name) {alert("You must find your way into the party and kill the VIP")};
party()
Additionally, you might not have embedded the script withing the proper tags to have it run. If I just put the preceding code into a file and save it as html it won't run because I haven't put it within the tags. See below for exact code:
<script>
var party = function (name) {alert("You must find your way into the party and kill the VIP")};
party()
</script>
Hope this helps!