dakus, 
 
<body>
 <script>
function middle(arr)
{
  let sum = 0;
  for (let x of arr) sum += x;
  let midpoint = sum / arr.length;
  let count = 0;
  for (let x of arr) count += x < midpoint ;
  return count;
}
let arr = [1, 2, 3, 4, 5]
document.body.append(middle(arr))
</script>
<br>
<script>
function maxMin(arr)
{
  let max = arr[0], min = arr[0];
  for (let x of arr) {
  if(x > max) max = x;
  if(x < min) min = x;
  }
  let clone = [], up = true;
  for (let x of arr) {
  if(x == min) up = false;
  if(up) x *= max;
  clone.push(x);
  }
  return {arr, clone, max, min};
}
let ar = [3, 2, 1, 4, 5];
document.body.append(JSON.stringify(maxMin(ar)));
</script>
</body>
	 |