CodeAgeBy Sitezack
Modern JavaScript for ProsES6+ and async0 XP
Chapter progress0/6

Lesson 2 of 6

Template literals and destructuring

Backticks create strings with slots: `${name} has ${xp} XP`. No more endless concatenations.

Destructuring extracts properties in one line: const {name, xp} = user;

const user = {name: 'Ada', xp: 120};
const {name, xp} = user;
console.log(`${name}:${xp}`);

🎯 Exercise

From const user = {name: 'Ada', xp: 120}: extract name and xp with destructuring, then write the string name:xp (with a template literal, exactly Ada:120) into #out.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO