A pot
Rose
A pot
Blackberry
A pot
Rose
A pot
Blackberry
A pot
Rose
123
let garden = "Rose\tBlackberry\t
Rose\tBlackberry\t
Rose";
123456
garden = garden
.replace(//i, "Blackberry");
Lesson 27 / 42

Lesson task •

Replace the first rose with blackberry.

Attention: now you are working with the garden written in a string with tabulation symbol delimiters

flag g

Replaces all the matches, not only the first match

When replacing with regular expressions, by default regular expressions replaces only the first match:

1
console.log("foo foo foo".replace(/foo/i, "bar")) // bar foo foo