JS Built-ins
← String148 / 195
StringString.prototype.toLocaleUpperCasebeginner

String.prototype.toLocaleUpperCase() β€” already uppercase

πŸ“– Usage Example
'hello'.toLocaleUpperCase()   // β†’ 'HELLO'
'world'.toLocaleUpperCase()   // β†’ 'WORLD'
'abc123'.toLocaleUpperCase()  // β†’ 'ABC123'

Use toLocaleUpperCase() to convert a string to uppercase using the locale-specific rules of the host environment.

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

If the string is already uppercase, toLocaleUpperCase() returns an equal string.

Challenge: Implement ensureUpper(str) and verify it works on already-uppercase strings.

ensureUpper('HELLO') // β†’ 'HELLO'
πŸ’‘ Hints (1)
  • β€’ Calling `toLocaleUpperCase()` on an uppercase string is a no-op.