Methods
Methods have parenthesis that imply a method to perform an action They are also written in camelCase
- .toLowerCase()
- .toUpperCase()
let name = "SaM"
let lowercased = name.toLowerCase()
console.log(lowercased) // "sam"
console.log(name) // "SaM" (unchanged)
Quick Recap
- The .toUpperCase() method makes a new copy of a string while converting every single character to uppercase.
- The .toLowerCase() method creates a copy of the string that is all in lower case.
- Pay attention to the way those methods are called: .toUpperCase() with a capital U and capital C. Same for .toLowerCase() with a capital L and capital C.
- The () at the end of the method are required.