Chapter 1 · Foundations

Text

You are reading the whole lesson on one page. Back to one step at a time

Step 1 of 22 · Concept

Text is a string

By the end of this lesson you can join text, put values into it, and turn it into numbers.

A text value is a string: characters between "..." or '...'. The quotes mark where it starts and ends; they are not part of it.

const name = "Ada";
console.log(name.length);

.length gives the number of characters: "Ada".length is 3. Like a number, a string sits in its box (lesson 2), and typeof name is "string" (lesson 3).

console.log("5" + 3, "5" * 2);
console.log('It's me');
const item = "tea";
const price = 2.5;
console.log(`${item}: ${price * 3}`);
const name = "Ada";
const age = 36;
// log one template literal here
console.log(Number("15") + 1, "15" + 1);
const total = 4.35 * 100;
console.log(total);
console.log(total.toFixed(2));
const count = 4;
const price = 2.25;
// log the label here
const name = "Ada";
console.log(name.toUpperCase(), Math.round(2.5), "a\nb");
// write your program here
const tea = 2.5;
const cake = 12;
const juice = 3.75;
console.log(`${tea.toFixed(2)} tea`);
console.log(`${cake.toFixed(2)} cake`);
console.log(`${juice.toFixed(2)} juice`);
Terminal
Step 1 of 10Text or number

Keyboard shortcuts

The step

ContinueEnter
Previous / next stepAlt+[ · Alt+]
Move along the steps bar← → Home End, then Enter
From a quiz's title to its answers↓
Skip to the stepTab, then Enter (first on the page)
Course outlineAlt+O
These shortcuts?

The workspace

Run the stepCtrl+Enter (⌘↵ on a Mac)
Lesson → editor → consoleF6 (Shift+F6 back)
Output ↔ TerminalCtrl+`
Focus the editorCtrl+. (⌘. on a Mac)
Hide or show the lessonAlt+L
Restore, close a messageEsc (outside the editor and the terminal)

The editor

Leave the editorF6 (Shift+F6 back); or Ctrl+M (⌃⇧M on a Mac), then Tab moves the focus (not in the vim mode)
Open a file by nameCtrl+P (⌘P on a Mac)
All commandsCtrl+Shift+P (⌘⇧P on a Mac) or F1
Go to a lineCtrl+G (⌃G on a Mac)
Show or hide the filesCtrl+B (⌘B on a Mac)
Previous / next file tabCtrl+Shift+[ · Ctrl+Shift+] (⌘⇧[ · ⌘⇧] on a Mac)
The file tabs← → Home End on a tab; Delete closes it
Save the files nowCtrl+S (⌘S on a Mac)
Go to a symbol in the fileCtrl+Shift+O (⌘⇧O on a Mac)
Go to the definitionF12
Format the fileCtrl+Shift+F (⌘⇧F on a Mac), or Shift+Alt+F
Go back / forward after a jumpAlt+← · Alt+→ (⌃- · ⌃⇧- on a Mac)