← all problems

middleCharacter 🌶️

Write a method that takes one String parameter, s, and returns the single character in the exact middle of s, as a one-character String. For example, middleCharacter("cat") should return "a". You may assume s always has an ODD number of characters (so there is always exactly one middle character), and at least one character.