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
    |
    4 Quizzes
  9. JavaScript: Iterators
    1Topic
    |
    1 Quiz
Lesson 2, Topic 7
In Progress

JavaScript: String Concatenation with Variables

Yasin Cakal 29 Oct 2021
Lesson Progress
0% Complete

We assigned strings to variables in previous exercises. Let’s look at how to join, or concatenate, strings in variables now.

Even if two string values are stored in variables, the + operator can be used to combine them:

let favFood= 'Pizza';
console.log('My favourite food is ' + favFood+ '.');

In the above example, we assigned the value Pizza to the variable favFood. The + operator is used on the second line to combine three strings: My favourite food is, the value saved to favFood, and .. The result of this concatenation is printed to the console as:

My favourite food is Pizza.

Responses

Leave a Reply

%d bloggers like this: