Back to Course

Introduction to JavaScript

0% Complete
0/0 Steps
  1. JavaScript: Basics
    9Topics
    |
    10 Quizzes
  2. JavaScript: Variables
    9Topics
    |
    10 Quizzes
  3. JavaScript: Conditional Statements
    10Topics
    |
    11 Quizzes
  4. JavaScript: Functions
    10Topics
    |
    11 Quizzes
  5. JavaScript: Scope
    6Topics
    |
    7 Quizzes
  6. JavaScript: Arrays
    11Topics
    |
    12 Quizzes
  7. JavaScript: Loops
    8Topics
    |
    9 Quizzes
  8. JavaScript: High Order Functions
    3Topics
    |
    3 Quizzes
Lesson 1, Topic 6
In Progress

JavaScript: String Concatenation

Yasin Cakal 27 Oct 2021
Lesson Progress
0% Complete

Operators are not only used to perform calculations on numbers! When the + operator is applied to two strings, the right string is appended to the left string.

console.log('Hu' + 'rray'); // Prints 'Hurray'
console.log('I am learning ' + 'javascript.')  // Prints 'I am learning javascript'

Concatenation is the process of adding one string to another. In the second case, we had to insert a space at the end of the first string. Because the computer will combine the strings exactly, we needed to include the space we desired between the two strings.

We may combine, or chain, our operations, just as in conventional math, to get the desired result:

console.log('Code' +   'Of' +   'Code!'); //Print CodeOfCode!
%d bloggers like this: