Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

typescript
uppercase
string
communitycreator

What is string.toUpperCase() in TypeScript?

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

TypeScript enables us to get the uppercase representation of a string. But the string.toUpperCase() method does not permanently modify the string. It only returns the string as uppercase.

Syntax

string.toUpperCase()
Syntax for toUpperCase() method in TypeScript

Parameter

string: This is the string we want to convert to uppercase.

Return value

This method returns the uppercase equivalent of the string string .

Code example

Let's look at the code below:

export {}
// create some strings.
let name:string = "Theodore"
let role:string = "Software Developer"
let nickName:string = "Kcee"
let hubby:string = "Coding"
// convert to uppercase
console.log(name.toUpperCase())
console.log(role.toUpperCase())
console.log(nickName.toUpperCase())
console.log(hubby.toUpperCase())
Get the uppercase equivalent of a string in TypeScript

Code explanation

  • Line 1: We export our file as a module.
  • Lines 4 to 7: We create some strings.
  • Lines 10 to 13: We use the toUpperCase() method to get the uppercase versions of our strings and print them to the console.

RELATED TAGS

typescript
uppercase
string
communitycreator

CONTRIBUTOR

Theodore Kelechukwu Onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring