Ad
Arrays
Data Types
Code
Diff
  • function remove(arr, n) {
      if (!arr[n]) return arr;
      arr.splice(n, 1);
      return arr;
    }
    • function remove(arr, n) {
    • const indexOutOfRange = n < 0 || n >= arr.length;
    • if (indexOutOfRange) return arr;
    • if (!arr[n]) return arr;
    • arr.splice(n, 1);
    • return arr;
    • }