Game prototype with methods to manage players
Bug

In this code, what is the return targetName = name line trying to achieve?


function findPlayer(playerName) { // assigned on line 9
  console.log('found', playerName);
  function isPlayer(targetName) {
    return targetName = name;
  }
  return this.players.find(isPlayer);
}



name is undefined, and probably you wanted to use == instead of =.

Also, the function should not print found ...,
before actually finding anything.

Code organization

The functions that should be called on Game instances should not be in the global namespace.
Not only they pollute the global namespace,
they are not useful and misleading without a Game instance.

Also, unless you want to allow manipulating the players array directly,
it would be better to hide it from users.

Printing inside functions is a bad practice unless it is their dedicated purpose.

This would be a better organization:

function createGame(title) {
  var players = [];

  function addPlayer(name) {
    players.push({ name: name });
  }

  function findPlayer(name) {
    return players.filter(function(player) { return player.name === name; });
  }

  function printPlayers() {
    console.log('Player list:');
    players.forEach(function(player, index) {
      console.log(index, player);
    });
  }

  return {
    title: title,
    addPlayer: addPlayer,
    findPlayer: findPlayer,
    printPlayers: printPlayers
  };
}


"just-in-case" programming

You made it possible to chain calls to createPlayer, along with this comment:


return this; // in case you want to chain? not sure...



When you're not sure to implement something,
there's a really simple rule of thumb you can follow: don't do it.
Everything in the code should have a purpose,
avoid writing code "just in case it might be useful someday".