for sorts the array in ascending and sorts the array in ascending order based on the average number of teeth that species possesses ( numTeeth ) but not work correctly can soeone help me
if I look at the docs for the .sort() method (link), I see:
Syntax
arr.sort([compareFunction])
Parameters
compareFunction Optional
Specifies a function that defines the sort order. If omitted, the array elements are converted to strings, then sorted according to each character’s Unicode code point value.
If I then look at the argument you provide:
return array.sort(parseInt(species.numTeeth, 10))
parseInt(species.numTeeth, 10) does not look like a function?
but if we make an array of species like this :
onst speciesArray = [ {speciesName:‘shark’, numTeeth:50}, {speciesName:‘dog’, numTeeth:42}, {speciesName:‘alligator’, numTeeth:80},{speciesName:‘human’, numTeeth:32},{speciesName:‘human’, numTeeth:9}] added an {speciesName:‘human’, numTeeth:9} in the array ,all the order wiil completly change so 9 will be in the last of order