Created
April 30, 2018 22:43
-
-
Save alexko30/e30bee7129b605fa0c1c21b3dc67c510 to your computer and use it in GitHub Desktop.
cubic Volume Difference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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