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
constby default;letonly when reassigning.- Backtick templates interpolate
${}and span lines. NumberandNumber.isNaNparse and check input.
Keywords and builtins used here
NumberconstisNaNlet
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.
Step 1 of 5 in Bindings & values, step 1 of 43 in Language basics.