what’s happening: I don’t know anymore dude…

Describe your issue in detail here.

so I’ve been working on this step of this section for roughly 5-ish hours now? trying to get the average of the middle two numbers of the array. I’ve tried so many different combinations of code that it would be useless to post them all here but I will try to give you the general logic I’m think of

- we are checking if the array.length is even or odd based on the remainder operator and the ternary operator.

2 if the number is even we need to add the middle two numbers of the array and get the average, that will be the median. – (I am stuck on this part as I am unsure to correctly code this using the getMean function. it seems to only want one array? I’ve tried adding them together then dividing the sum by 2 but that doesn’t seem to work, maybe I’m just an idiot though)

3 if the number is odd the middle number is the median and math.floor will make sure the the array index is rounded down to the nearest whole number – I don’t think I have trouble understanding this part but at this point I’m throwing code spaghetti at the wall and seeing what sticks.

so if anyone could read through my logic, maybe find out where I’m going wrong that would be helpful, I’ve already read many of the other threads pertaining to this issue and none of them really helped me but I am willing to re read them in case I missed something

### Your code so far

const median = array.length % 2 === 0 ? getMean(sorted[sorted.length/2]+ sorted[sorted.length/2-1]) : sorted[Math.floor(sorted.length/2)]

}

// User Editable Region

### Your browser information:

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

### Challenge Information:

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