Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 1.4 — Strings Basics
JavaScript · Example 1 of 4

Quotes and escape sequences

\n printed as a real line break, so one console.log made two lines.

A string is text: a fixed sequence of characters in quotes. You can write it three ways, escape special characters, insert values with template literals, read its length and single characters, but never change it in place.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Store a city and a temperature in variables and log It is 31°C in Pune today. using a template literal.

02

Log the first and last character of any word you choose, without typing the index of the last character by hand.

03

Log a two-line address with a single console.log call.

Explain it without notes

01

What is the difference between single quotes, double quotes and backticks?

02

What does it mean that strings are immutable? Give an example.

03

Why is "😀".length equal to 2?

Quotes and escape sequences

Console

(nothing was printed)

Expected console output

She said "hi"
It's fine
It's fine too
Line one
Line two
C:\Users\asha
Price: ₹500
3
0