Contenido del Curso
Introduction to JavaScript
Introduction to JavaScript
3. Performing Operations in JavaScript
Understanding Assignment OperatorsMathematical Operations in JavaScriptAssignment Operators in JavaScriptIncrement and Decrement OperatorsChallenge: Variable Operations PracticeComparison Operators in JavaScriptLogical Operators ExplainedChallenge: Compare Variables in JavaScriptConcatenating Strings in JavaScriptChallenge: Build Sentences with JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
Concatenating 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:
let wordOne = "Hello"; let wordTwo = "World"; console.log(wordOne + wordTwo);
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:
let wordOne = "Hello"; let wordTwo = "World"; console.log(wordOne + ", " + wordTwo + "!");
Concatenation with Assignment
The +=
operator allows you to add text to a string-type variable:
let text = "Were"; text += "wolf"; text += "!"; console.log(text)
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 9