Strings In Depth18 / 18
Up next

Match with a regex

const s = "cat hat bat";
// a global regex collects every match into an array
const words = s.match(/\wat/g);
console.log(words);
What you're solving

global match returns all hits