There is no way to return a value from forEach
.
Just use a for
loop instead.
bool nameExists(players, player) {
for(var f in players) {
if (f.data['name'].toLowerCase() == player.toLowerCase()) {
return true;
}
}
return false;
}