Camp 2 · Schritt 6 von 18
Strings and template literals
Join, measure, and transform text — and meet backtick strings, the modern way to build sentences.
14 Min.+50 XPAuf Englisch angezeigt — Übersetzung ist unterwegs
Text in JavaScript is a string, written with "double" or 'single'
quotes — identical in meaning, pick one and be consistent.
Joining with +
JavaScript
Workable — but stitching many values with + " " + gets ugly fast. Modern
JavaScript has something better.
Template literals: backtick strings
Wrap text in backticks (`) and embed any expression with
${...}:
JavaScript
Real expressions work inside ${} — math, function calls, anything. This
is JavaScript's equivalent of Python's f-strings, and your default tool
from here on.
Everyday string tools
JavaScript
.length— character count (no parentheses — it's a property).toUpperCase()/.toLowerCase().includes(...)— true/false containment check.replace(old, new)— swap the first match
Checkpoint
What prints here?
const n = 5;
console.log(`${n} + ${n} = ${n + n}`);Checkpoint
What is "trail".length?
What's next
The type behind every decision: booleans — plus the difference between
== and === that trips up half the internet.