I have an endpoint that returns back a string in a JSON, i.e.:
"<p>Rationalize the denominator of each expression. Write your answer in simplest form.</p><p><code class='latex inline'>\n\\displaystyle\n\\frac{\\sqrt{3}+\\sqrt{5}}{\\sqrt{2}}\n</code></p>"
When I try to use that string in JavaScript, it automatically converts it to:
"<p>Rationalize the denominator of each expression. Write your answer in simplest form.</p><p><code class='latex inline'> \displaystyle \frac{\sqrt{3}+\sqrt{5}}{\sqrt{2}} </code></p>"
The backslashes are gone as it reads it as an escape character instead of it being a part of the string. I need these backslashes to persist in the string, but I lose it before I can manipulate it in any way. What can I invoke to keep the string as it is originally?
Rationalize the denominator of each expression. Write your answer in simplest form.
".replace(/\\/g, "\\\\");` – Unmitigated Jul 21 '20 at 00:44\n\\displaystyle\n\\frac{\\sqrt{3}+\\sqrt{5}}{\\sqrt{2}}\n