smallestProduct
Given a non-empty array of non-empty integer arrays, multiply the contents of each nested array and return the smallest total.
by trentHarlem
HTML
<h1>
smallestProduct
</h1>
<p>
Given a non-empty array of non-empty integer arrays,<br> multiply the contents of each nested array and return the smallest total.
</p>
JavaScript
function smallestProduct(arr) {
return arr.map(intArr=>intArr.reduce((a,c) => a*c)).reduce((a,c)=> a<c?a:c)
}
//.sort((a,b)=> a-b)
//.reduce((a,c)=> a<c?a:c)
//Math.min(prod)
console.log(smallestProduct([[3, 2], [1, 2, 1], [7, 8]]), 2)