OneCompiler

JavaScript pyramid volume calculation in three lines

239

const baseArea = (baseLength1, baseLength2) => baseLength1 * baseLength2;
const triangleVol = (height, baseArea) => (height * baseArea) * 0.25;
console.log(${triangleVol(5, baseArea(5, 6))}cm³);