-7

I want to show below description in an alert in javascript. but it shows Uncaught SyntaxError: Invalid or unexpected token. Here I am using special characters like ',? & and so on. Please help me with it.

This is my description to show in an alert:

This is alert box code :

alert("This's guide you how to work ?.");

Sample code is :

    <span id="event-desc-label" class="infolabel">First game of the
    playoffs, who's in?<br>
<br>If you still owe money for next session, bring it. I will be
    finalizing the roster <br>Restrictions: No Restrictions<br> <a
    href="#" onclick="alert(&quot;First game of the playoffs, who" s=""
    in?\n\nif="" you="" still="" owe="" money="" for="" next="" session,=""
    bring="" it.="" i="" will="" be="" finalizing="" the="" roster="" in=""
    coming="" days.="" \nrestrictions:="" no="" restrictions\n")'="">...more</a>
</span>
Kumaresan Perumal
  • 131
  • 1
  • 1
  • 13
  • 1
    What did you tried so far. Write some code. – Shoaib Konnur Dec 17 '16 at 13:52
  • 1
    `alert(This guide teaches...` - well that's not a string you're using. `I'm currently working on a JavaScript implementation of the Java 8 Streams API for the browser.` Why would you want to do that? Streams an attempt to bring functional programming concepts to an OO language - JS is _already_ a functional language. – VLAZ Dec 17 '16 at 13:55

1 Answers1

1

This works form me:

alert("This guide teaches you how to work with Java 8 streams and how to use the different kind of available stream operations. You'll learn about the processing order and how the ordering of stream operations affect runtime performance. The more powerful stream operations reduce, collect and flatMap are covered in detail. The tutorial ends with an in-depth look at parallel streams.If you're not yet familiar with Java 8 lambda expressions, functional interfaces and method references, you probably want to read my Java 8 Tutorial first before starting with this tutorial.UPDATE - I'm currently working on a JavaScript implementation of the Java 8 Streams API for the browser. If I've drawn your interest check out Stream.js on GitHub. Your Feedback is highly appreciated.");

If you are using ' ' as a string, then you you have to escape the " ' " like this ' \' '

Device
  • 574
  • 4
  • 19
  • 2
    @KumaresanPerumal OK, you're doing something about Java. I presume you know Java - how would you deal with a user who have you a string and you try to do `System.out.println(userString)` with it? It's the same solution here. – VLAZ Dec 17 '16 at 14:01
  • no that is description for alert box. i am not using java. i am using js – Kumaresan Perumal Dec 17 '16 at 14:03
  • Ffs man, he said "How would you do this in java, it's the same in js" – Device Dec 17 '16 at 14:05
  • just escape the freaking strings, are you def? – Device Dec 17 '16 at 14:06
  • replace ' with \' and " with \", I assume that you are not programming for the first time – Device Dec 17 '16 at 14:08