CJCoding With Joseph
15free / daySign inCreate account

The Replace method returns a new string in which every occurrence of one piece of text is swapped for another. You call it as text.Replace(oldValue, newValue). You are given a string named sentence set to "I like cats". Use Replace to swap the word "cats" for "dogs" and print the updated sentence. The original string is not modified — Replace hands back a fresh string with the change applied.

Expected output

I like dogs

= newline. The output ends with a newline, so print one after the last line.

Hints2 available
Topics
Strings
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)

Your output

Run your code to see the output here...

Test cases

Run your code to see test case results.