//strings example
const name = 'Peter';
const name1 = "Jack";
const result = `The names are ${name} and ${name1}`;
// JavaScript String
const data =
{
"name": "John Doe",
"age": 45
}
function Sample() { return "TEXT"; }
var str1 = 'With " in it "';
var str2 = "With ' in it '";
var str3 = `Contains other Strings >${str1}<, Properties of objects >${data.age}< or return values from functions >${Sample()}<.`;
console.log(str1); // With " in it "
console.log(str2); // With ' in it '
console.log(str3); // Contains other Strings >With " in it "<, Properties of objects >45< or return values from functions >TEXT<.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Strings</h2>
<p>You can use quotes inside a string, as long as they don't match the quotes surrounding the string:</p>
<p id="demo"></p>
<script>
var answer1 = "It's alright";
var answer2 = "He is called 'Johnny'";
var answer3 = 'He is called "Johnny"';
document.getElementById("demo").innerHTML =
answer1 + "<br>" +
answer2 + "<br>" +
answer3;
</script>
</body>
</html>
//In Javascript, a string can be declared using "" or ''.