{"size": 737, "ext": "js", "max_stars_repo_path": "utilities/addToClass.js", "max_stars_repo_name": "Ewager1/Devfit", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "utilities/addToClass.js", "max_issues_repo_name": "Ewager1/Devfit", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "utilities/addToClass.js", "max_forks_repo_name": "Ewager1/Devfit", "max_forks_repo_forks_event_min_datetime": "2021-03-20T17:05:26.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-23T17:23:31.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 26.3214285714, "max_line_length": 62, "alphanum_fraction": 0.6770691995}
module.exports = function (selectedClass, memberid) {
  let isAlreadyEnrolled = false;

  //Pulls class roster and checks if user is already joined
  const oldRoster = selectedClass.roster;
  oldRoster.forEach((member) => {
    if (JSON.stringify(memberid) === JSON.stringify(member)) {
      isAlreadyEnrolled = true;
    }
  });

  if (!isAlreadyEnrolled) {
    //Adds user to roster and updates class size
    oldRoster.push(memberid);
    const newClassSize = oldRoster.length;
    const newRosterJoined = oldRoster;

    const classUpdate = {
      roster: newRosterJoined,
      current_size: newClassSize,
    };
    return classUpdate;
  } else {
    // Our error should go here
    return console.log("Member enrolled");
  }
};
