JS Built-ins
← String163 / 195
StringString.prototype.toUpperCasebeginner

String.prototype.toUpperCase() β€” already uppercase unchanged

πŸ“– Usage Example
'hello world'.toUpperCase()   // β†’ 'HELLO WORLD'
'abc'.toUpperCase()           // β†’ 'ABC'
'xyz123'.toUpperCase()        // β†’ 'XYZ123'

Use toUpperCase() to convert all alphabetical characters in a string to uppercase.

String.prototype.toUpperCase() β€” Already Uppercase

If all letters are already uppercase, toUpperCase() returns an equivalent string.

Challenge: Implement ensureUppercase(str) using toUpperCase.

ensureUppercase('HELLO') // β†’ 'HELLO'
πŸ’‘ Hints (1)
  • β€’ `toUpperCase()` is safe to call on already-uppercase strings.