0

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?

Pang
10.2k146 gold badges87 silver badges126 bronze badges
asked Feb 11, 2015 at 2:11
1
  • 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" Commented Feb 11, 2015 at 2:14

4 Answers 4

1

you must define your function before using it.

answered Feb 11, 2015 at 2:18
Sign up to request clarification or add additional context in comments.

Comments

0

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.

answered Feb 11, 2015 at 2:14

Comments

0

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()
answered Feb 11, 2015 at 2:13

Comments

0

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!

answered Feb 11, 2015 at 2:18

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.