typestar

Variables and template literals in JavaScript

Bindings and string interpolation, the modern defaults.

const name = "typestar";
let score = 0;
score += 10;

const greeting = `Hello, ${name}! You have ${score} points.`;
const multiline = `line one
line two`;

const PI = 3.14159;
const rounded = PI.toFixed(2);
const parsed = Number("42");
const isNumber = !Number.isNaN(parsed);

How it works

  1. const by default; let only when reassigning.
  2. Backtick templates interpolate ${} and span lines.
  3. Number and Number.isNaN parse and check input.

Keywords and builtins used here

The run, in numbers

Lines
12
Characters to type
275
Tokens
71
Three-star pace
80 tpm

At the three-star pace of 80 tokens a minute, this run takes about 53 seconds.

Type this snippet

Step 1 of 5 in Bindings & values, step 1 of 43 in Language basics.

Next →