Home

Published

- 1 min read

multi-line string shorthand javascript

img of multi-line string shorthand javascript

The solution for this is noted below

multi-line string shorthand javascript

Solution

   // Multi-line String Shorthand
// Longhand:
const lorem =
	'Lorem ipsum dolor sit amet, consectetur\n\t' +
	'adipisicing elit, sed do eiusmod tempor incididunt\n\t' +
	'ut labore et dolore magna aliqua. Ut enim ad minim\n\t' +
	'veniam, quis nostrud exercitation ullamco laboris\n\t' +
	'nisi ut aliquip ex ea commodo consequat. Duis aute\n\t' +
	'irure dolor in reprehenderit in voluptate velit esse.\n\t'
console.log(lorem)

// Shorthand: use backtick
const lorem_ = `Lorem ipsum dolor sit amet, consectetur
    adipisicing elit, sed do eiusmod tempor incididunt
    ut labore et dolore magna aliqua. Ut enim ad minim
    veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat. Duis aute
    irure dolor in reprehenderit in voluptate velit esse.`
console.log(lorem_)

Try other methods by searching on the site. That is if this doesn’t work