Skip to content

Instantly share code, notes, and snippets.

@alexko30
Created April 30, 2018 22:43
Show Gist options
  • Save alexko30/e30bee7129b605fa0c1c21b3dc67c510 to your computer and use it in GitHub Desktop.
Save alexko30/e30bee7129b605fa0c1c21b3dc67c510 to your computer and use it in GitHub Desktop.
cubic Volume Difference
function cubicVolumeDifference(cub1, cub2) {
let cubSum1 = 1;
let cubSum2 = 1;
for (let i = 0; i < cub1.length; i++) {
cubSum1 *= cub1[i];
}
for (let i = 0; i < cub2.length; i++) {
cubSum2 *= cub2[i];
}
const differ = cubSum2 - cubSum1;
if(differ > 0) {
console.log('Cub 2 volume is grater for', differ);
} else if (differ < 0) {
console.log('Cub 1 volume is grater for', Math.abs(differ));
} else {
console.log('Equals');
}
}
cubicVolumeDifference([2, 2, 3], [2, 2, 2.4]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment