Centered Average

I don't want any single line of code , I just don't get what the question really means/wants. A little bit confused of what I'm supposed to do, if anyone can give me a few more input examples and the output.

Thank you.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore just one copy, and likewise for the largest value. Use int division to produce the final average. You may assume that the array is length 3 or more.

centeredAverage({1, 2, 3, 4, 100}) → 3
centeredAverage({1, 1, 5, 5, 10, 8, 7}) → 5
centeredAverage({-10, -4, -2, -4, -2, 0}) → -3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Last edited on
{1, 2, 3, 4, 100}
ignore the smallest and largest value
{2, 3, 4}
compute the average
(2+3+4) / 3 = 3


{1, 1, 5, 5, 10, 8, 7}
There are two copies of the smallest value, ignore just one
{1, 5, 5, 8, 7}
compute the averate
(1+5+5+8+7) / 5 = 5.2
truncate the result
5
Ohhh, thanks alot, that made everything clear.
Topic archived. No new replies allowed.