A pot
Rose
A pot
Primrose
A pot
Rosemary
A pot
ChristmasRose
A pot
EchinaceaSunrise
12345
let garden = [
	"Rose", "Primrose", "Rosemary", 
	"Christmas Rose", 
	"Echinacea 'Sunrise'"
];
123456
for  (const plant of garden) {
if (plant.match(//i) {
water(plant);
}
}
Lesson 6 / 42

Lesson task •

Water plants ending with "rose"

End of string

$

Points to the end of string. The pattern before it will be applied to the end of the string but not to the other parts

You can restrict your pattern to match only those substrings that include the end of string by using $:

12
console.log(!!"foo bar".match(/bar$/)) // true 
console.log(!!"bar foo".match(/bar$/)) // false 

If you need to match "$" literally than you have to escape it with backslash:

12345
console.log(!!"foo$".match(/foo\$/)) // true 
console.log(!!"foo$".match(/foo\$$/)) // true 
console.log(!!"foo$".match(/foo$/)) // false 
console.log(!!"$foo".match(/\$foo/)) // true 
console.log(!!"$foo".match(/$foo/)) // false