Swacblooms🦋

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

Search and Replace

Sammy 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

Translate the provided string to pig latin. Pig Latin takes the …

The Pig Latin Challenge

convert from binary to text
Write a function that takes in arguments of binaries and …

Binary To Text

About The Author

Sammy

I am Samson Amaugo. I am a full-stack web developer and I specialize in MERN stack development

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

  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫
  • Deploying a DotNet API To Railway 🚂
  • GitHub OAuth Device Flow in DotNet

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

  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫
  • Deploying a DotNet API To Railway 🚂
  • GitHub OAuth Device Flow in DotNet
  • Resumable Download in DotNet
  • Mocking the HttpClient in C#
  • MySocials DotNet CLI Tool
  • Benchmarking in C#
  • C# bang bang operator

Swacblooms🦋

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