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

Tell us what’s happening:

what is the problem with this code. I have been trying a lot of suggestions
Describe your issue in detail here.

Your code so far

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

Your browser information:

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

Challenge Information:

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

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

you never close the square bracket here

I have closed it yet, it is has not passed the challenge.

Please, can you write the complete code with explanation for better understanding.

Please post your updated code.

please show your code. It’s forum policy to not give direct solutions but we can keep helping you if you show your last code

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

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

}

Why not use the getMean function you coded earlier to do this?