Ad

Without using Array.prototype.flat() implement a flatten function.

Eg.

flatten([1, [2, [3]], 4]) // returns [1, 2, 3, 4]
function flatten(input) {
  return input.reduce((arr, value) => {
    return [
      ...arr,
      ...(Array.isArray(value) ? flatten(value) : [value])
    ];
  }, []);
}