Click to reopen instructions.

Recursion over strings. Every method here is written the same way: a base case for the empty string (or a very short one), and a recursive case that does something with the first character and the answer for the rest of the string. The starter code provides helpers for taking a string apart: first(s) returns the first character, rest(s) returns everything after it, and isVowel(c) says whether a character is a vowel. You may also use isEmpty(), charAt, and substring from the String class.

Strings are a nice place to do recursion because, unlike lists, it’s easy to build up a new one: first(s) + rest(s) is a new string. Several of these methods build their answer that way. No loops and no streams; the point is the recursion. And no reaching for the library method that already does the job.

Put definitions here.

Revisions:

Test results show up here.

Errors