Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Multiline Strings. Concatenating | JavaScript syntax
Introduction to JavaScript

Glissez pour afficher le menu

book
Multiline Strings. Concatenating

Concatenating Multiple Lines

We can implement a multi-line string by concatenation of every line of the multi-line string to the variable. Below we have a code example for it:

1234
let myStr = "This is my" + " multiline String " + " which is amazing"; console.log(myStr);
copy
Tâche

Swipe to start coding

Take two variables named firstPart and secondPart and assign the values of "This is a" and " JavaScript book." respectively. The task is to concatenate the above variables using the + operator and store the concatenated string in a variable named book, and show value on the console.

Solution

Summary:

  • A string which comes on more than one line in the code is called Multiline String.

  • Template literals are used to implement multi-line string by using backticks.

  • Backslashes are used to implement multiline string.

  • Concatenation is used to implement multiline string.

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 13
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

Awesome!

Completion rate improved to 2

book
Multiline Strings. Concatenating

Concatenating Multiple Lines

We can implement a multi-line string by concatenation of every line of the multi-line string to the variable. Below we have a code example for it:

1234
let myStr = "This is my" + " multiline String " + " which is amazing"; console.log(myStr);
copy
Tâche

Swipe to start coding

Take two variables named firstPart and secondPart and assign the values of "This is a" and " JavaScript book." respectively. The task is to concatenate the above variables using the + operator and store the concatenated string in a variable named book, and show value on the console.

Solution

Summary:

  • A string which comes on more than one line in the code is called Multiline String.

  • Template literals are used to implement multi-line string by using backticks.

  • Backslashes are used to implement multiline string.

  • Concatenation is used to implement multiline string.

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

close

Awesome!

Completion rate improved to 2

Glissez pour afficher le menu

some-alt