Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Primitive Data Types · Lesson 10 of 15

Strings

A free lesson from Swipe Coding · JavaScript, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
Almost every program you'll ever write needs to work with text somewhere. This is where that starts. 📝

Strings hold text. JavaScript gives you three ways to write a string literal: single quotes 'Hi', double quotes "Hi", and backticks `Hi` — all three produce a string. Unlike Java, JavaScript has no separate character type: a single letter like 'A' is simply a string with a length of 1.

const single = 'Hello';
const double = "World";
const backtick = `Hi there`;
console.log(single, double, backtick);
Three equivalent ways to write a string literal — pick one style and stay consistent.
🤖
Interpolation is one of those features that makes you never want to go back. ✨

Backtick strings are called template literals, and they have a superpower: you can embed expressions directly inside them using ${ } — called interpolation — without gluing pieces together with +.

const name = 'Ada';
console.log(`Hello, ${name}!`); // "Hello, Ada!"
The value of name is inserted directly into the template literal.

The + operator concatenates (joins) strings together. Whenever at least one side of + is a string, JavaScript converts the other side to text and joins them, rather than performing addition.

const first = 'Java';
const second = 'Script';
console.log(first + second);   // "JavaScript"
console.log('Score: ' + 95);   // "Score: 95"
+ joins strings end to end, and automatically converts a number to text when one side is already a string.
Fill in the blank

Backtick strings, called ____ literals, let you embed expressions directly inside ${ }.

Quick check

What does 'Hello, ' + 'World' produce?

True or false

JavaScript has a separate type for a single character, just like Java's char.

Keep your streak going in Swipe Coding

Swipe through every level of JavaScript on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →