In Swift, the localizedCapitalized
property returns the capitalized representation of a string instance that is produced using the current locale.
string.localizedCapitalized
This property returns a capitalized representation of a string using the current locale.
// import the foundation frameworkimport Foundation// create stringslet str1 = "google"let str2 = "netflix"let str3 = "amazon"let str4 = "apple"let str5 = "meta"// get the capitalized representationprint(str1.localizedCapitalized)print(str2.localizedCapitalized)print(str3.localizedCapitalized)print(str4.localizedCapitalized)print(str5.localizedCapitalized)
Foundation
framework. This allows us to use the localizedCapitalized
property.localizedCapitalized
on the strings and print the output to the console.