Is there a way to make the first letter in the text Uppercase and the others lowercase?
I am trying to use:
("weatherCondition").toString().toUpper()); ,but it doesn't work for me.
Thanks
Is there a way to make the first letter in the text Uppercase and the others lowercase?
I am trying to use:
("weatherCondition").toString().toUpper()); ,but it doesn't work for me.
Thanks
As you've found, your code makes all the characters in the string uppercase, not just the first one.
Use String.substring() to split the input into 2 pieces (1st letter and the remaining letters). Use toUpper() on the first piece, use toLower() on the second piece, and return the concatenation of the two resulting pieces.
function titleCase(str as String) as String { return str.substring(0, 1).toUpper() + str.substring(1, str.length()).toLower(); }