Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
String Concatenation | Basic Operations
Introduction to JavaScript
course content

Conteúdo do Curso

Introduction to JavaScript

Introduction to JavaScript

1. Basic Concepts
2. Variables and Data Types
3. Basic Operations
4. Conditional Statements
5. Loops
6. Functions

bookString Concatenation

Let's explore some operations that you can perform with strings in JavaScript.

Concatenation

Concatenation is the process of combining two strings. This operation is achieved using the + operator:

1234
let wordOne = "Hello"; let wordTwo = "World"; console.log(wordOne + wordTwo);
copy

You can see that concatenation creates a new string by combining two words.

Note

String concatenation does not automatically add spaces. You need to manually include spaces like string1 + " " + string2.

Let's create a nicely formatted string through concatenation:

1234
let wordOne = "Hello"; let wordTwo = "World"; console.log(wordOne + ", " + wordTwo + "!");
copy

Concatenation with Assignment

The += operator allows you to add text to a string-type variable:

12345
let text = "Were"; text += "wolf"; text += "!"; console.log(text)
copy
What will be the output?

What will be the output?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 9
some-alt