Skip to content Skip to sidebar Skip to footer

Javascript Syntax Error Unexpected Token Illegal

function queue_instructions(){ var input_message = 'Commands w? Shows whos on the waitlist w+ Adds yourself to the waitlist w- Removes yourself from the wait

Solution 1:

You 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"+

Solution 2:

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.

Solution 3:

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.

Solution 4:

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 [command] for more info on a command (ie. -help w?)"
].join("\n");

Solution 5:

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

Post a Comment for "Javascript Syntax Error Unexpected Token Illegal"