this challenge could be solved with the array.prototype.find method and I am reading the documentation but I am getting stuck at this part which says
callbackFn is invoked for every index of the array, not just those with assigned values. This means it may be less efficient for sparse arrays, compared to methods that only visit assigned values.
what does it mean by callback function not just those with assigned values what are those assigned values
Sparse arrays are arrays with “holes” in them, i.e. [1, 2,,4,,6]. What the docs is saying is that the find() callback is invoked no matter if the element has an assigned value or not.
If more than one trailing comma is used, an elision (or hole) is produced. An array with holes is called sparse (a dense array has no holes). When iterating arrays for example with Array.prototype.forEach() or Array.prototype.map(), array holes are skipped.