Computer >> Computer tutorials >  >> Programming >> Javascript

Converting strings to uppercase and lowercase with vanilla JavaScript


Javascript provides toUpperCase and toLowerCase functions on the String object prototype that allows conversion of strings to uppercase and lowercase with vanilla JavaScript.

toUpperCase

Example

let str = "Hello World"
let upper = str.toUpperCase()
console.log(upper)

Output

This will give the output −

HELLO WORLD

toLowerCase

Example

let str = "Hello World"
let lower = str.toLowerCase()
console.log(lower)

Output

This will give the output −

hello world