JavaScript Multiline String – How to Create Multi Line Strings in JS
Laucha

Laucha

calendar iconAug 10, 2022

JavaScript Multiline String – How to Create Multi Line Strings in JS

In this article, you will learn three different ways to create multi-line strings in JavaScript.

I will first explain the basics of strings in JavaScript and go over how to use template literals. Then, you will learn how to create a string that spans multiple lines with the help of code examples along the way.

Here is what we will cover:

What Is A String in JavaScript? An Intro on How to Create A String in JS

Strings are an effective way of communicating through text.

A string is an ordered sequence of character values. Specifically, a string is a sequence of one or more characters that can be either letters, numbers, or symbols (such as punctuation marks).

There are three ways you can create a string in JavaScript:

Here is how to create a string using single quotes:

// string created using single quotes ('')let favePhrase = 'Hello World!';

Here is how to create a string using double quotes:

// string created using double quotes ("")let favePhrase = "Hello World!";

Here is how to create a string using backticks:

// string created using backticks (``)let favePhrase = `Hello World!`;

The last way of creating strings in JavaScript is known as a template literal.

I created a variable named favePhrase.

Laucha

Laucha

Admin

Leave a Reply

Related Posts

Categories