function customReverse() {
  // DO NOT REMOVE
  'use strict';

  // Write your solution below
  if (this === null || this === undefined) {
    throw new TypeError('Array.prototype.every called on null or undefined');
  }

  const list = Object(this);
  const length = list.length || 0;

  if (!length) {
    return this;
  }

  const mid = parseInt(length / 2);
  let temp;
  let i = 0;
  let j;

  while (i < mid) {
    j = length - i - 1;
    const lowerExists = Object.prototype.hasOwnProperty.call(list, i);
    const upperExists = Object.prototype.hasOwnProperty.call(list, j);

    if (lowerExists && upperExists) {
      temp = this[i];
      this[i] = this[j];
      this[j] = temp;
    } else if (!lowerExists && upperExists) {
      this[i] = this[j];
      delete this[j];
    } else if (lowerExists && !upperExists) {
      this[j] = this[i];
      delete this[i];
    }
    
    i += 1;
  }

  return this;
}

Array.prototype.customReverse = customReverse;
Read-only