{"size": 941, "ext": "js", "max_stars_repo_path": "src/transform-array.js", "max_stars_repo_name": "chfius/basic-js", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/transform-array.js", "max_issues_repo_name": "chfius/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": "chfius/basic-js", "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": 36.1923076923, "max_line_length": 91, "alphanum_fraction": 0.4123273114}
module.exports = function transform(arr) {
    // throw 'Not implemented';
    // remove line with error and write your code here
    const commands = ['--discard-next', '--discard-prev', '--double-next', '--double-prev']
    let arrNew = [];
    if (Array.isArray(arr)) {
        for (let i = 0; i < arr.length; i++) {
            if (commands.includes(arr[i])) {
                if (arr[i] == '--discard-next') {
                    i++;
                } else if (arr[i] == '--discard-prev') {
                    arrNew.pop();
                } else if ((arr[i] == '--double-next') && (i !== arr.length - 1)) {
                    arrNew.push(arr[i + 1]);
                } else if ((arr[i] == '--double-prev') && (i > 0)) {
                    arrNew.push(arr[i - 1]);
                }
            } else {
                arrNew.push(arr[i]);
            }
        }
        return arrNew;
    } else {
        throw 'Error';
    }
};