Converting strings to uppercase and lowercase with vanilla JavaScript

JavascriptFront End TechnologyObject Oriented Programming

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
raja
Published on 02-Dec-2019 10:59:28
Advertisements