This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Animate Your Name Forum

View Course

301 points
532ffc8f631fe915ae008c4b_929057727
Submitted by
Cansu Kaya
about 3 years ago

[resolved] Why \ symbol is not allowed when I write a string?

When I type ~ document.write( "Cansu\" ); ~ string, an error returns:Uncaught SyntaxError: Unexpected token ILLEGAL.

Simply, why can't I use \ symbol in a string?

Thanks!


1 vote

permalink

The backslash character is used as the escape character. This means that you cannot include one in your string unless you escape it, in other words you must type two of them together (\\).

Having an escape character comes in handy when you need to print quotes within quotes and also some unprintable characters like tabs and line feeds.

3691 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
about 3 years ago

2 Comments

532ffc8f631fe915ae008c4b_929057727 Cansu Kaya about 3 years ago

Thank you ^^

55df2afa95e3787b9200005e_359368177 Judy about 3 years ago

You're welcome!