Library reference

Convert text to uppercase

Give these short labels the same letter case. All four inputs use plain English letters and digits.

toUpperCase

Simple example

Change the case of two letters.

Start'ab'
ResultAB
lesson.ts
console.log("ab".toUpperCase());
Output
AB
Advertisements

Everyday examples

Make the bus label match the route board.

Start'bus'
ResultBUS
lesson.ts
console.log("bus".toUpperCase());
Output
BUS

Give an art shelf the same lettering as the other shelves.

Start'art'
ResultART
lesson.ts
console.log("art".toUpperCase());
Output
ART

Normalize the letters in a ticket code and keep its digits.

Start'b12'
ResultB12
lesson.ts
console.log("b12".toUpperCase());
Output
B12
Run the example
Terminal
tsc --target ES2020 lesson.ts
node lesson.js
Official documentation