# Bug in Learn Advanced Array Methods by Building a Statistics Calculator - Step 59

### Tell us what’s happening:

Step 59 asks the user to fix that the .sort() method is mutating the array which it is called on by adding a .slice(), but this was already addressed in Step 26 by replacing the .sort() method with a .toSorted() method. You can of course get past this final step by reverting to the .sort() method and then following the instructions of Step 59, but you really shouldn’t have to.

``````<!-- file: index.html -->

``````
``````/* file: script.js */
// User Editable Region

const getMedian = (array) => {
const sorted = array.toSorted((a, b) => a - b);
const median =
sorted.length % 2 === 0
? getMean([sorted[sorted.length / 2], sorted[sorted.length / 2 - 1]])
: sorted[Math.floor(sorted.length / 2)];
return median;
}

// User Editable Region
``````
``````/* file: styles.css */

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36`

### Challenge Information:

Learn Advanced Array Methods by Building a Statistics Calculator - Step 59

Thank you for helping make FCC better. Bugs can be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

looks like step 59 should be deleted completely. Please open the issue on github as suggested by Ilenia.

Here’s what I did to pass this step.
I changed from .toSorted() to .sort() in the sorted variable declaration and added a .slice() call before the .sort() method.

you didn’t need to do that. It’s clearly a mistake in the project that should be fixed.