Working with Text
7 min · JavaScript
Join strings, measure them, and drop values into template literals.
Enemy 1 of 5
This code joins two strings with + to build one greeting and prints it. Press Run to see the combined text.
Why this works
Text values are called strings: any sequence of characters inside quotes, from a single letter to a full sentence. You've been using them for every console.log call so far; now it's time to combine and manipulate them.
Join two strings with +, the same operator used for addition, but JavaScript uses it for concatenation (gluing text together) whenever at least one side is a string. This double duty is convenient once you're used to it, but it's exactly why mixing numbers and strings with + can surprise you, as the previous lesson mentioned.
Rena
Your AI tutor. She walks you through each step.
Asking for help is part of coding. Rena reads your code and gives you a hint. She is free with an account: 20 hints a day.