The Word Swapper
Medium+20 XP
Mission Briefing
A sabotage attempt has injected the word "Bad" into the Royal Decree! You must act quickly as the official Word Swapper to fix the document before it reaches the public.
The Concept: String Manipulation
The .replace(target, replacement) method finds the first occurrence of a specific string and replaces it with a new one.
Example: "I am sleepy".replace("sleepy", "awake"); // Returns "I am awake"
The Objective
Your function receives a sentence string.
- Find the exact word "Bad" (case-sensitive) and replace it with "Good".
- Return the modified sentence. (Note: You only need to replace the first occurrence!)
01EXAMPLE 1
Input
sentence = "This is a Bad idea"Output
"This is a Good idea"Constraints
- Return the modified string.
CoreStrings
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
sentence"The Bad news"
Expected Output
The Good news
Click RUN to test your solution