JSFiddle - React, Tailwind, and code Playground
by BurpmanJunior
CSS
html,
body{
font-family: monospace;
}
strong{
text-decoration: underline;
}
JavaScript
/**
* BOX VOLUME
*/
function boxVolume(x, z, y){
return Math.max(0, (x * z * y));
}
var boxes = [
[1, 1, 1],
[3, 4, 2],
[5.7, 4.2, 9],
[187, 112, 473]
];
for (var i = 0; i < boxes.length; i++) {
var str = 'width: ' + boxes[i][0] + 'cm, ';
str += 'depth: ' + boxes[i][1] + 'cm, ';
str += 'height: ' + boxes[i][2] + 'cm = ';
str += boxVolume(boxes[i][0], boxes[i][1], boxes[i][2]) + ' cm<sup>3</sup><br />';
document.body.innerHTML = document.body.innerHTML + str;
}