-
-
Notifications
You must be signed in to change notification settings - Fork 147
Add String transformer workshop to main with steps and tests #1014
Copy link
Copy link
Closed
freeCodeCamp/freeCodeCamp
#62557Labels
Description
We will be adding this workshop after the Working with String Modification Methods theory block.
const originalString = "I love cats.";
console.log("Original string:");
console.log(originalString);
const replacedString = originalString.replace("cats", "dogs");
console.log("After using the replace() method:");
console.log(replacedString);
const exampleSentence = "I love cats and cats are so much fun!";
console.log("Original string:");
console.log(exampleSentence);
const replaceAllOccurences = exampleSentence.replaceAll("cats", "dogs");
console.log("Replacing all occurences of cats with dogs:");
console.log(replaceAllOccurences);
const learningSentence = "I love learning!";
console.log("Original Sentence:");
console.log(learningSentence);
// this could be broken down into two steps
const repeatedLove = "love ".repeat(3).trimEnd();
const newSentence = `I ${repeatedLove} learning.`;
console.log("Modified Sentence:");
console.log(newSentence);
Reactions are currently unavailable