{"size": 1112, "ext": "js", "max_stars_repo_path": "utils/index.js", "max_stars_repo_name": "musakacmaz/the-office-quotes-game", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utils/index.js", "max_issues_repo_name": "musakacmaz/the-office-quotes-game", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "utils/index.js", "max_forks_repo_name": "musakacmaz/the-office-quotes-game", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.2727272727, "max_line_length": 80, "alphanum_fraction": 0.559352518}
export function buildChoices(quoteOwner, characters) {
  const choices = [];

  while (choices.length < 3) {
    let randomCharacter =
      characters[Math.floor(Math.random() * characters.length)];
    if (
      randomCharacter._id !== quoteOwner._id &&
      !choices.some((choice) => choice.id === randomCharacter._id)
    ) {
      choices.push({
        id: randomCharacter._id,
        text:
          (randomCharacter.firstname !== "null"
            ? randomCharacter.firstname
            : "") +
          " " +
          (randomCharacter.lastname !== "null" ? randomCharacter.lastname : ""),
        isOwner: false,
      });
    }
  }

  choices.push({
    id: quoteOwner._id,
    text:
      (quoteOwner.firstname !== "null" ? quoteOwner.firstname : "") +
      " " +
      (quoteOwner.lastname !== "null" ? quoteOwner.lastname : ""),
    isOwner: true,
  });

  return shuffleArray(choices);
}

function shuffleArray(array) {
  for (let i = array.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [array[i], array[j]] = [array[j], array[i]];
  }

  return array;
}
