Johnsoct
12/21/2017 - 3:17 PM

Remove Index from Array

A helper function that removes an index from an array using either the index or the value of the index you're looking for ( universal ).

function splice( array, index = '', value = '') {
  if (index) {
    array.splice(index, 1);
  }
  if (value) {
    array.forEach(i => {
      if (array[i] = value) {
        array.splice(i, 1);
      }
    });
  }
}