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.
string.toUpperCase()
string
: This is the string we want to convert to uppercase.
This method returns the uppercase equivalent of the string string
.
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 uppercaseconsole.log(name.toUpperCase())console.log(role.toUpperCase())console.log(nickName.toUpperCase())console.log(hubby.toUpperCase())
toUpperCase()
method to get the uppercase versions of our strings and print them to the console.