Loading challenge...
Preparing the challenge details...
Loading challenge...
Preparing the challenge details...
Implement Array.prototype.flat from scratch with a configurable depth. Default depth is 1, not Infinity.
flat flattens nested arrays up to a given depth. The interviewer check: do you default depth to 1 (not Infinity) and do you pass the depth counter through recursion correctly? flat(Infinity) should fully flatten any level of nesting.
Goal: Implement myFlat with correct default depth and recursive depth tracking.
Continue learning with these related challenges
Implement Array.prototype.map from scratch. Master callback signatures, thisArg binding, and sparse-array hole preservation.
Implement Array.prototype.filter from scratch. The key detail: push the original element, not the boolean result of the predicate.
Implement Array.prototype.reduce from scratch, including the tricky no-initial-value path and the empty-array error case.
Implement Array.prototype.map from scratch. Master callback signatures, thisArg binding, and sparse-array hole preservation.
Implement Array.prototype.filter from scratch. The key detail: push the original element, not the boolean result of the predicate.
Implement Array.prototype.reduce from scratch, including the tricky no-initial-value path and the empty-array error case.