Prev Demo
JavaScript
>
Strings In Javascript
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>JavaScript Strings</h1> <h3>Variables in Single and Double Quotes</h3> <div id="myId"></div> <script> var x = "Sheo Narayan"; var y = 'SN ITFunda'; document.getElementById("myId").innerHTML = x + "<br>" + y </script> <p><strong>Note:</strong> Observe the variables values in the script code, variable 'x' value kept in double quote, variable 'y' value kept in single quote.</p> <br/> <h3>Inserting Quotes inside the string</h3> <div id="getId"></div> <script> var a = "This is 'DotNetFunda'"; var b = 'This is "TechFunda"'; var c = "This is 'KidsFunda' & 'FarmingFunda'"; document.getElementById("getId").innerHTML = a + "<br>" + b + "<br>" + c </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output