Skip to main content

Practice ยท 2 of 5

Spec under camouflage

CHALLENGE
Difficulty: intermediate+25 XP

A 'text conditioner' applies two rules in order: (1) if the text is shorter than 3 characters (or null), return it unchanged; (2) otherwise return only its **middle two** characters (for even length, the two straddling the center; for odd length, the center character plus the one after it). Implement process(String s). Examples: "code" โ†’ "od", "abc" โ†’ "bc", "ab" โ†’ "ab", "x" โ†’ "x".

Back to lesson: Practice: Reading specs like the exam writes them