0

in js file i wrote function to return string and calling this function is script tag inside HTML file

function getExp()
{
    var exp = "]]><!\\[CDATA\\[";
    return exp;
}

but its returning

]><!\[CDATA\[

what is the issue why string is not returned by function as it is ?

2 Answers 2

4

It's because you're using '\' (escape key) in your string so it's ignoring the text to the right of that. try this instead.

var exp = "]]><!\\\\[CDATA\\\\["
Sign up to request clarification or add additional context in comments.

2 Comments

no success i tried this and what abt starting 2 rectangular closing brackets
If that doesn't work there is another issue with your code. exp is correct. Try running it in the console.
0

Try this

function getExp()
{
   var exp = "\]]><!\\\\[CDATA\\\\[";
   return exp;
}

Its return

 ]]><!\\[CDATA\\[

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.