Skip to content

Add String transformer workshop to main with steps and tests #1014

@jdwilkin4

Description

@jdwilkin4

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);
Image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions