Swacblooms🦋

Making the Moves
Menu
  • Home
  • Motivation
  • Education
  • Programming
  • About
  • Contact
  • Privacy Policy
Home
Programming
Search and Replace
Programming

Search and Replace

Samson Amaugo March 29, 2019

Perform a search and replace on the sentence using the arguments provided and return the new sentence.

First argument is the sentence to perform the search and replace on.

Second argument is the word that you will be replacing (before).

Third argument is what you will be replacing the second argument with (after).

Note
Preserve the case of the first character in the original word when you are replacing it. For example if you mean to replace the word “Book” with the word “dog”, it should be replaced as “Dog”

Your code should satisfy the following conditions

  • myReplace("Let us go to the store", "store", "mall")should return “Let us go to the mall”.
  • myReplace("He is Sleeping on the couch", "Sleeping", "sitting")should return “He is Sitting on the couch”.
  • myReplace("This has a spellngi error", "spellngi", "spelling")should return “This has a spelling error”.
  • myReplace("His name is Tom", "Tom", "john")should return “His name is John”.
  • myReplace("Let us get back to more Coding", "Coding", "algorithms")should return “Let us get back to more Algorithms”.

Try to establish your code using this function template

function myReplace(str, before, after) {
  return str;
}

myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");

Send link to your code in the comment section below. You can use any editor of your choice

Prev Article
Next Article

Related Articles

the path to mastery
  Hi pals! Probably most of you out there have …

Mastery and what it takes

error
Hello folks, so in this post, I would be talking …

Typescript: The Error Saving Ninja

About The Author

Samson Amaugo

I am Samson Amaugo. I am a full-stack developer and I specialize in DotNet and the MERN stack.

One Response

  1. Sammy

    This is a link to mine
    https://code.sololearn.com/Wy8hcoNYXqit

    March 29, 2019

Leave a Reply

Cancel reply

Search Site

Recent Posts

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#

Categories

  • EDUCATION
  • Motivation
  • Programming
  • Uncategorized

Get more stuff

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

RSS Swacblooms

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#
  • Hot Chocolate Data Loader: A Quick Guide
  • Exploring Policy-Based Authorization in Minimal API with .NET 8
  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫

Swacblooms🦋

Making the Moves
Copyright © 2025 Swacblooms🦋
Swacblooms - Making the Moves