forEach accepts a function and runs it for every element in the array. You can’t break the loop. If you want to exit from a single run of the function, you use return.
If you want to be able to break the loop, you have to use for..of loop:
for(let name of group.names){
if (name == 'SAM') {
break;
}
}