1/*
2 Use to format long strings without crossing ruler length
3 or affecting string display. NOTE: use grave-accents/backticks: `
4*/
5function getLongString() {
6 return `
7 Bacon ipsum dolor amet boudin pastrami shankle ham fatback
8 pork. Short ribs ham beef, filet mignon ball tip sirloin
9 shankle t-bone drumstick. Ground round drumstick pancetta
10 fatback alcatra.
11 `;
12}
13
14function getDynamicMessage() {
15 const personName = "Dave Dude";
16 const whatever = (((1 + 2) * 3) / 4);
17 return `
18 Hello, ${personName}! Here's a very long string with
19 some dynamic values in, such as: ${whatever}`;
20}
1
2// OPTION 1
3var MultilineString = `This
4is
5a multiline
6string`; // Note: use the template quotation marks above the tab key
7
8// OPTION 2
9var MultilineString = 'This \n\
10is \n\
11a multiline \n\
12string'; // Note: use the "\n\" as a newline character
1 // Creating multi-line string
2 var str = `<div class="content">
3 <h1>This is a heading</h1>
4 <p>This is a paragraph of text.</p>
5 </div>`;
6
7 // Printing the string
8 document.write(str);