Method Chaining
Method chaining means calling one method after another in a single expression.
It is useful when each method returns a value that the next method can use.
Without Method Chaining
let username = window.prompt("Enter your username")
username = username.trim()
let firstLetter = username.charAt(0)
firstLetter = firstLetter.toUpperCase()
let extraChars = username.slice(1)
extraChars = extraChars.toLowerCase()
username = firstLetter + extraChars
console.log(username)With Method Chaining
let username = window.prompt("Enter your username")
username =
username.trim().charAt(0).toUpperCase() +
username.trim().slice(1).toLowerCase()
console.log(username)