replaceOnce 🌶️🌶️
Write a method that takes three String parameters, text, target and replacement, and returns text with the first occurrence of target replaced by replacement. For example, replaceOnce("I like cats", "cats", "dogs") should return "I like dogs", and replaceOnce("aaa", "a", "b") should return "baa". Build it with indexOf and substring.
Precondition: target appears in text at least once.
How many pieces make up the answer here, and what's in the middle one?
Where exactly does the piece after the target begin? Does it depend on the target's length?