hmm, js quotation marks problem _? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

hmm, js quotation marks problem _?

Ok so, so far I know of these quotation marks `` , '' , "" Those three. And I've used all of them in my code. 'cod.js..lbleblahblah'; var x = "a" u.innerHTML = `<h2> wow </h2>` Now, I want to turn the code into a string. But, it's not gonna work, cuz that' just how it is and it will read the code as ... some as variables... and it would just be mixed up. It just doesn't work that way. I guess You could try it, but ..ye I was wondering if there was a 4th quotation mark, or a work around this. ?

15th Nov 2020, 5:03 AM
Ginfio
Ginfio - avatar
4 Respuestas
+ 2
You can use the backticks (``) but also have to escape the inner-backticks like so: var str = `function(){ var x = ‘ndjd’ var y = “hd” var d = \`ndksksm\` }`
15th Nov 2020, 6:54 PM
ODLNT
ODLNT - avatar
+ 2
you can use replace() method in js let html = "<span>i am html</span> let rep = html.replace(/</g, ”&lt;") with replace method you can replace < with its html entity character , which will be printed on page but not get rendered https://code.sololearn.com/Wo2UC3lH72QS/?ref=app
15th Nov 2020, 5:37 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
Or just write how you want it between the quotes. There are several of these character code that can be used to display various types of characters in your strings. u.innerHTML = "&lt;h2&gt; wow &lt;/h2&gt;" https://www.rapidtables.com/web/html/html-codes.html https://www.w3schools.com/html/html_symbols.asp
15th Nov 2020, 5:43 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
ChaoticDawg im not talking about special characters. im talking about specifically quotation marks: “”, ‘’, ``etc. I used all of them in my code, now i want to make the code a string but cant. function(){ var x = ‘ndjd’ var y = “hd” var d = `ndksksm` } now i want to make the above code a string.. var string = ‘function... ..}’
15th Nov 2020, 5:13 PM
Ginfio
Ginfio - avatar