Missing ) after argument list

P

paul.denlinger

I'm using Firebug to debug a JavaScript function call. Here is the
JavaScript:

// JavaScript Document// define the functions
function PrintCard() {
line1 = "<b>Name: </b>" + this.name + "<br>\n";
line2 = "<b>Address: </b>" + this.address + "<br>\n";
line3 = "<b>Work Phone: </b>" + this.workphone + "<br>\n";
line4 = "<b>Home Phone: </b>" + this.homephone + "<hr>\n";
document.write(line1, line2, line3, line4);
}
function Card(name,address,work,home) {
this.name = name;
this.address = address;
this.workphone = work;
this.homephone = home;
this.PrintCard = PrintCard;
}
// Create the objects
sue = new Card("Sue Suthers", "123 Elm Street", "555-1234"
"555-9876");
phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222"
"555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle", "555-1299,
"555-1344");
// And print them
sue.PrintCard();
phred.PrintCard();
henry.PrintCard();

Firebug is telling me that "missing ) after argument list" in the line
beginning "sue=new Card...", but I don't see any missing ).

Can someone help?

Thank you.
 
E

Evertjan.

I'm using Firebug to debug a JavaScript function call. Here is the
JavaScript:

// JavaScript Document// define the functions
function PrintCard() {
line1 = "<b>Name: </b>" + this.name + "<br>\n";
line2 = "<b>Address: </b>" + this.address + "<br>\n";
line3 = "<b>Work Phone: </b>" + this.workphone + "<br>\n";
line4 = "<b>Home Phone: </b>" + this.homephone + "<hr>\n";
document.write(line1, line2, line3, line4);
}
function Card(name,address,work,home) {
this.name = name;
this.address = address;
this.workphone = work;
this.homephone = home;
this.PrintCard = PrintCard;
}
// Create the objects
sue = new Card("Sue Suthers", "123 Elm Street", "555-1234"
"555-9876");
phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222"
"555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle", "555-1299,
"555-1344");

Correcting these Create lines will eliminate the errors in IE and FF.
You miss two commas and a closing doublequote.

// Create the objects
sue = new Card("Sue Suthers", "123 Elm Street",
"555-1234","555-9876");
phred = new Card("Phred Madsen",
"233 Oak Lane", "555-2222","555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle",
"555-1299","555-1344");
 
T

Tim Streater

I'm using Firebug to debug a JavaScript function call. Here is the
JavaScript:

// JavaScript Document// define the functions
function PrintCard() {
line1 = "<b>Name: </b>" + this.name + "<br>\n";
line2 = "<b>Address: </b>" + this.address + "<br>\n";
line3 = "<b>Work Phone: </b>" + this.workphone + "<br>\n";
line4 = "<b>Home Phone: </b>" + this.homephone + "<hr>\n";
document.write(line1, line2, line3, line4);
}
function Card(name,address,work,home) {
this.name = name;
this.address = address;
this.workphone = work;
this.homephone = home;
this.PrintCard = PrintCard;
}
// Create the objects
sue = new Card("Sue Suthers", "123 Elm Street", "555-1234"

Missing a comma in previous line.
"555-9876");
phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222"

Missing a comma in previous line.
"555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle", "555-1299,

Missing closing quote before comma in previous line.
 
T

Tim Streater

Evertjan. said:
Correcting these Create lines will eliminate the errors in IE and FF.
You miss two commas and a closing doublequote.

By the way these were very simple errors. Paul, you shouldn't need to
come here to have these fixed. One thing that would help would be an
editor that does syntax colouring - that will point up for example
unterminated quotes.

Also - don't expect error messages to be 100% correct. If it looks like
the debugger is lying, then suspect something else - as in this case :)
 
H

Henry

On Jul 16, 4:12 pm, (e-mail address removed) wrote:
sue = new Card("Sue Suthers", "123 Elm Street", "555-1234"
"555-9876");
phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222"
"555-4444");
Firebug is telling me that "missing ) after argument list" in the line
beginning "sue=new Card...", but I don't see any missing ).
<snip>

The final argument in that line (and the one after it) is not
separated from the penultimate argument by a comma. Thus the
interpreter is reading a (comma separated) arguments list and then it
encounters a string literal when it is expecting to see either a comma
token or a closing parenthesis token. One of these two tokens is
missing and so the error produced states the one that is most likely
be erroneously omitted.
 
T

The Natural Philosopher

Henry said:
On Jul 16, 4:12 pm, (e-mail address removed) wrote:


<snip>

The final argument in that line (and the one after it) is not
separated from the penultimate argument by a comma. Thus the
interpreter is reading a (comma separated) arguments list and then it
encounters a string literal when it is expecting to see either a comma
token or a closing parenthesis token. One of these two tokens is
missing and so the error produced states the one that is most likely
be erroneously omitted.

One compiler I used years ago had a much better warning "extremely long
string statement, are you sure you haven't left a literal out?"
 
P

paul.denlinger

Can you suggest a debugger which provides more helpful error
messages?

I'm just starting out learning JavaScript; my impression is that a
good tool for experienced JS programmers, but it might not be as
helpful for someone just learning.

I'm running Win XP.

Thank you.
 
P

paul.denlinger

(e-mail address removed) wrote on 16 jul 2007 in comp.lang.javascript:





Correcting these Create lines will eliminate the errors in IE and FF.
You miss two commas and a closing doublequote.

// Create the objects
sue = new Card("Sue Suthers", "123 Elm Street",
"555-1234","555-9876");
phred = new Card("Phred Madsen",
"233 Oak Lane", "555-2222","555-4444");
henry = new Card("Henry Tillman", "233 Walnut Circle",
"555-1299","555-1344");

Thank you; it works!
 
T

Tim Streater

Can you suggest a debugger which provides more helpful error
messages?

I'm just starting out learning JavaScript; my impression is that a
good tool for experienced JS programmers, but it might not be as
helpful for someone just learning.

I'm running Win XP.

Well, I don't use XP for this type of task but it looks like EditPad or
some other programmer's editor might help you (not EditPad Lite, tho). I
use a Mac, and use TextWrangler, which does syntax colouring according
to the language in use. I find that helpful to avoid mis-typed keywords,
unterminated strings, misplaced braces, etc. That way you can eliminate
most typos before trying to run your code.

Time was when compilers ploughed on and gave you lots of messages -
which was necessary back then because your job was batched and you
probably only got a couple of chances a day to run it. So you really
needed as much info as possible from each attempt.

Nowadays compilers/interpreters seem to give up at the first error, and
as you saw, the message you get doesn't necessarily correspond to the
actual error. I would just take any message like the one you got as an
indication that you have a typo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top