Loading challenge...
Preparing the challenge details...
Loading challenge...
Preparing the challenge details...
Implement Array.prototype.map from scratch. Master callback signatures, thisArg binding, and sparse-array hole preservation.
Rebuilding map forces you to think about what it actually does: call a function on every element, collect the results in a new array, and never touch the original. The details that trip people up are passing all three arguments to the callback (element, index, array), supporting the optional thisArg, and preserving holes in sparse arrays.
Goal: Implement myMap in under 15 minutes. Make sure all three callback arguments work and thisArg is respected.
Continue learning with these related challenges
Implement Array.prototype.filter from scratch. The key detail: push the original element, not the boolean result of the predicate.
Implement Array.prototype.flat from scratch with a configurable depth. Default depth is 1, not Infinity.
Implement Array.prototype.reduce from scratch, including the tricky no-initial-value path and the empty-array error case.
Implement Array.prototype.filter from scratch. The key detail: push the original element, not the boolean result of the predicate.
Implement Array.prototype.flat from scratch with a configurable depth. Default depth is 1, not Infinity.
Implement Array.prototype.reduce from scratch, including the tricky no-initial-value path and the empty-array error case.