SberTest
Интуиция

# Code
```javascript []
/**
 * @param {Array} arr
 * @param {number} depth
 * @return {Array}
 */

var flat = function(array, depth) {
  const result = [];

  function flatten(arr, level) {
    for (let item of arr) {
      if (Array.isArray(item) && level > 0) {
        flatten(item, level - 1);
      } else {
        result.push(item);
      }
    }
  }

  flatten(array, depth);

  return result;
};
```
['JavaScript']