Multiline Strings
What are multi-line strings?
This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.
Following are the ways to get multi-line strings:
- Multi-line strings using template literals.
- Multi-line strings using a backslash.
- Multi-line strings using concatenating multiple lines.
Multi-line strings using template literals:
we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.
12345let myStr = `This is my multiline String which is amazing`; console.log(myStr);
Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.
1234let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
Swipe to start coding
You are given a string variable name foxJump
. Your task is to split the string into three lines using backticks and display the output.
Solución
¡Gracias por tus comentarios!
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Resumir este capítulo
Explicar el código en file
Explicar por qué file no resuelve la tarea
Awesome!
Completion rate improved to 2
Multiline Strings
Desliza para mostrar el menú
What are multi-line strings?
This is a string that comes on more than one line. In JavaScript you may come across a situation where you have to store a multi-line string in a variable in your JavaScript. Strings that can not be shortened.
Following are the ways to get multi-line strings:
- Multi-line strings using template literals.
- Multi-line strings using a backslash.
- Multi-line strings using concatenating multiple lines.
Multi-line strings using template literals:
we can use template literals that use backticks to define multiline strings and for expression evaluation in too in strings.
12345let myStr = `This is my multiline String which is amazing`; console.log(myStr);
Multi-Line Strings using Backslash:
Adding a backslash at the end of every line in a multiline string works, too. This can be a bit confusing as we are adding a special symbol to escape the new line character.
1234let myStr = "This is my \ multiline String \ and it is amazing"; console.log(myStr);
Swipe to start coding
You are given a string variable name foxJump
. Your task is to split the string into three lines using backticks and display the output.
Solución
¡Gracias por tus comentarios!
Awesome!
Completion rate improved to 2single