Closed odv closed 5 years ago
function findDifference(a, b) {
return a.reduce((a,b) => a * b) > b.reduce((a,b) => a * b) ? a[0]*a[1]*a[2] - b[0]*b[1]*b[2] : b[0]*b[1]*b[2] - a[0]*a[1]*a[2];
}
Improved solution using Math.abs method
function findDifference(a, b) {
return Math.abs(a.reduce((a,b) => a * b) - b.reduce((a,b) => a * b));
}
https://www.codewars.com/kata/difference-of-volumes-of-cuboids/train/javascript