Regex-problem(last element)

let string = 'This is good to eat';
let power = /eat$/g;
let result = string.match(power);
console.log(result);

Can anyone explain ,the regex is not selecting the last element despite using $ character.

Your regex is returning the correct result. But it is returning an Array because you used the global flag.