---
# System prepended metadata

title: 23T3 07A

---

```javascript=
import promptSync from 'prompt-sync';

const product = (numbers: number[]) => numbers.reduce((a: number, b: number) => a * b, 1);

/**
 * Given an array of n integers, caclulate the minimum, maximum, and the
 * product of the first n-1 numbers and last n-1 numbers.
 */
function drykiss(myList: number[]) {
  const myMin = Math.min(...myList);
  const myMax = Math.max(...myList);
  const prodHead = product(myList.slice(0, -1));
  const prodTail = product(myList.slice(1));

  return [myMin, myMax, prodHead, prodTail];
}

const prompt = promptSync();

const myNums = [];
for (const letter of 'abcde') {
    const num = parseInt(prompt(`Enter ${letter}: `));
    myNums.push(num);
}

const [min, max, head, tail] = drykiss(myNums);

console.log(`
  Minimum:
  ${min}
  Maximum:
  ${max}
  Product of first ${myNums.length} numbers:
  ${head}
  Product of last ${myNums.length} numbers:
  ${tail}
  `.trim().replace(/\n\s+/g, '\n')
)

```
