Skip to content
Justice Tech School

Numbers and Strings

number covers integers and floats. bigint holds huge integers. Template literals with backticks insert values with ${}. String methods: toUpperCase, includes, slice, split, padStart, trim.

Example
const n: number = 17 / 5;
const big: bigint = 9007199254740993n;
const s = "Hello, TypeScript";
console.log(n.toFixed(1), big, s.length);
console.log(`${s.toUpperCase()} has ${s.split(" ").length} words`);
console.log("7".padStart(3, "0"), s.slice(7));

Result

3.4 9007199254740993n 17
HELLO, TYPESCRIPT has 2 words
007 TypeScript

Exercise

Insert a value in a template.

`Hi name}`

Quiz Test

Which quotes allow ${}?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.