← Back to challenges

Maximum and Minimum Product Triplets

JavaScriptHardnumbersarrays

Instructions

Write two functions:

  1. One that returns the maximum product of three numbers in an array.
  2. One that returns the minimum product of three numbers in an array.

Examples

maxProduct([-8, -9, 1, 2, 7]) ➞ 504

maxProduct([-8, 1, 2, 7, 9]) ➞ 126

minProduct([1, -1, 1, 1]) ➞ -1

minProduct([-5, -3, -1, 0, 4]) ➞ -15

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.