Hello,
I am trying to make a function that returns the string str in all lowercase. The console is saying that
String allLowercase (String str) must return a result of type string. I’m stumped and obviously a little lost, can anyone point me in the right direction?
void setup () {
String str = "ABCD 123, Fall 2019, Pizza";
String lowerStr = allLowercase (str);
println(lowerStr);
}
String allLowercase (String str) {
String res="";
char c;
for (int i = 0; i < str.length();++i){
c = str.charAt(i);
if (c >= 'A' && c <= 'Z'){
c=(char)(c+32);
res = res+c;
return res;
} else {
return null;
}
}
}