# Help with functions

**URL:** <https://discourse.processing.org/t/help-with-functions/14885>\
**Category:** Coding Questions\
**Created:** [October 23, 2019, 1:28am UTC](https://discourse.processing.org/t/help-with-functions/14885 "2019-10-23T01:28:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JackBarrie1341](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@JackBarrie1341](https://discourse.processing.org/u/JackBarrie1341)\
**Post date:** [October 23, 2019, 1:28am UTC](https://discourse.processing.org/t/help-with-functions/14885/1 "2019-10-23T01:28:18Z")

</div>

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?

```auto
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;
    }
    
}

 }

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 23, 2019, 1:36am UTC](https://discourse.processing.org/t/help-with-functions/14885/2 "2019-10-23T01:36:00Z")

</div>

i think i see the same home work here last week,  
did you use search here ( or google search ) already?

hope it helps: [Calling a function for making a string lowercase without predefined function](https://discourse.processing.org/t/calling-a-function-for-making-a-string-lowercase-without-predefined-function/14775)

* * *

possibly only the program flow,  
while the rest looks good

```auto
void setup () {
  String str = "ABCD 123, Fall 2019, Pizza";
  println(str);
  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;
}

```
