function queue_instructions(){
var input_message = "Commands
w? Shows whos on the waitlist
w+ Adds yourself to the waitlist
w- Removes yourself from the waitlist
w++ Moves yourself down one spot on the waitlist
-mods Shows a list of available moderators
-plays Shows how many songs each DJ has played
-promote Requests a vote from everyone for you to be moved to 1st on the list
-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right
-remove [#] Removes that number DJ from the waitlist Must be a moderator
-votekick [username] Requests a vote from everyone to kick the user
Type -help [mand] for more info on a mand (ie. -help w?)";
deliver_chat(input_message);
I get a syntax error unexpected toke illegal on my Javascript console on Google chrome. Any ideas?
function queue_instructions(){
var input_message = "Commands
w? Shows whos on the waitlist
w+ Adds yourself to the waitlist
w- Removes yourself from the waitlist
w++ Moves yourself down one spot on the waitlist
-mods Shows a list of available moderators
-plays Shows how many songs each DJ has played
-promote Requests a vote from everyone for you to be moved to 1st on the list
-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right
-remove [#] Removes that number DJ from the waitlist Must be a moderator
-votekick [username] Requests a vote from everyone to kick the user
Type -help [mand] for more info on a mand (ie. -help w?)";
deliver_chat(input_message);
I get a syntax error unexpected toke illegal on my Javascript console on Google chrome. Any ideas?
Share Improve this question edited Dec 23, 2011 at 4:59 Lion 19k22 gold badges82 silver badges111 bronze badges asked Dec 23, 2011 at 4:47 Nick GoadNick Goad 4311 gold badge5 silver badges6 bronze badges5 Answers
Reset to default 3You have to close those quotes on each line, and concatenate with +
to the next line:
var input_message = "Commands " +
"w? Shows whos on the waitlist " +
"w+ Adds yourself to the waitlist " +
and so on
Did you want line breaks to be inserted with each line? If so, you can use \n
:
var input_message = "Commands\n" +
"w? Shows whos on the waitlist\n" +
"w+ Adds yourself to the waitlist\n" +
When you split a string over multiple lines, you need to concatenate it with +
like this
var input_message = "Commands"+
"w? Shows whos on the waitlist"+
"w+ Adds yourself to the waitlist"+
"w- Removes yourself from the waitlist"+
"w++ Moves yourself down one spot on the waitlist"+
"-mods Shows a list of available moderators"+
"-plays Shows how many songs each DJ has played"+;
And also in your code, I don't find the closing curly brace }
of that function.
function queue_instructions()
{
//Stuff here.
}
you need to include it.
Your syntax is incorrect. You'll need to either put the whole string in one line OR close the quotes in each line a do a + to concat the next line with it.
Or you do like this:
var input_message = [
"Commands",
"w? Shows whos on the waitlist",
"w+ Adds yourself to the waitlist",
"w- Removes yourself from the waitlist",
"w++ Moves yourself down one spot on the waitlist",
"-mods Shows a list of available moderators",
"-plays Shows how many songs each DJ has played",
"-promote Requests a vote from everyone for you to be moved to 1st on the list",
"-pull [#] Requests a vote from everyone to pull that DJ off the booth Number of DJ is what number spot he is on the booth Numbers read from left to right",
"-remove [#] Removes that number DJ from the waitlist Must be a moderator",
"-votekick [username] Requests a vote from everyone to kick the user",
"Type -help [mand] for more info on a mand (ie. -help w?)"
].join("\n");
I notice no-one has suggested escaping the line-ending:
var multiStr = "This is the first line \
This is the second line \
This is more...";
Note that the line endings are included in this string…
http://davidwalsh.name/multiline-javascript-strings