edwin1
1
### 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

system
2
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.

ilenia
3
you never close the square bracket here

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

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

Teller
5
Please post your updated code.

ilenia
6
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

edwin1
7
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);

}

edwin1
8
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);

}

Teller
9
Why not use the `getMean`

function you coded earlier to do this?