Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Concatenating Strings in JavaScript | Performing Operations in JavaScript
Introduction to JavaScript

bookConcatenating Strings in JavaScript

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
question mark

What will be the output?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 9

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

bookConcatenating Strings in JavaScript

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
question mark

What will be the output?

Select the correct answer

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

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