Changing the title from JavaScript
The getter trimmed and collapsed the messy whitespace. Click the button to see the title change again; in a real tab, the tab text would update.
The <title> names the page on tabs, bookmarks and search results, and the meta description is your suggested summary under it; both should be unique, specific and short enough not to be cut off.
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 6 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write a title and a meta description for a page that sells a blue cotton school bag for ₹899 on a shop called BagBazaar.
Write a JavaScript function setUnread(n) that sets the title to Inbox — Mailo when n is 0 and to (n) Inbox — Mailo otherwise. Call it with 0 and 5 and log the title.
Explain it without notes
Name five places where a page's <title> is used.
What makes a good title for a recipe page, and why does word order matter?
Does the meta description affect ranking? Why write one anyway?
Why might Google show a different title than the one you wrote?
Preview
Console
Nothing logged yet.Expected console output
Tidied title: Inbox — Mailo
After update: (2) Inbox — Mailo