Skip to main content

Checkpoint: the middle pair

Challenge on lesson: Checkpoint: middle pair

CHALLENGE
Difficulty: advanced+25 XP

Return the **middle two characters** of any string of length ≥ 2 — for even length the two straddling the center, for odd length the center character plus the one after it. (Shorter strings: return them unchanged.) Implement process(String s). Examples: "code" → "od", "abcde" → "cd", "ab" → "ab".

Back to lesson: Checkpoint: middle pair