{"size": 863, "ext": "js", "max_stars_repo_path": "src/transform-array.js", "max_stars_repo_name": "AntonBazhan/basic-js", "max_stars_repo_stars_event_min_datetime": "2021-01-13T19:46:49.000Z", "max_stars_repo_stars_event_max_datetime": "2021-01-13T19:46:49.000Z", "max_issues_repo_path": "src/transform-array.js", "max_issues_repo_name": "AntonBazhan/basic-js", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/transform-array.js", "max_forks_repo_name": "AntonBazhan/basic-js", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.96875, "max_line_length": 57, "alphanum_fraction": 0.4797219003}
module.exports = function transform(arr) {
  const array = [...arr];
  array.map((element, index) => {
    if (element === "--discard-next") {
      // if (element.length < index) {
      //   array.splice(index, 1);
      // }
      array.splice(index, 2, "delete");
    } else if (element === "--discard-prev") {
      if (index === 0) {
        array.splice(0, 1);
      } else {
        array.splice(index - 1, 2, "delete");
      }
    } else if (element === "--double-prev") {
      if (index === 0) {
        array.splice(0, 1);
      } else {
        array.splice(index, 1, array[index - 1]);
      }
    } else if (element === "--double-next") {
      if (array.length === index + 1) {
        array.pop();
      } else {
        array.splice(index, 1, array[index + 1]);
      }
    }
  });

  return array.filter((element) => element !== "delete");
};
