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

String.prototype.toUpperCase() β€” empty string

πŸ“– 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() β€” Empty String

Calling toUpperCase() on an empty string returns an empty string.

Challenge: Implement safeUpper(str) using toUpperCase.

safeUpper('') // β†’ ''
safeUpper('hi') // β†’ 'HI'
πŸ’‘ Hints (1)
  • β€’ `"".toUpperCase()` returns `""`.