This commit is contained in:
Philippe Torrel
2026-06-23 15:00:23 +02:00
parent ae62a154b3
commit 3da605979d
2 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kartonvolumen berechnen (cube)</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<main>
<div class="container py-5">
<h1>Kartonvolumen berechnen (cube)</h1>
</div>
</main>
<script>
'use strict';
// Konfigurationsvariablen
const BASE_COST_PER_UNIT = 0.7;
const COST_PER_CC = 0.001;
const length = 25;
const width = 30;
const height = 12;
// cubeVolume = length × width × height
const cartonVolume = length * width * height;
// shippingCost = volume × costPerCC + costPerUnit
const shippingCost = cartonVolume * COST_PER_CC + BASE_COST_PER_UNIT;
console.log(`shipping cost is: $${shippingCost.toFixed(2)}`); // => 9.70
</script>
</body>
</html>

View File

@@ -0,0 +1,61 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kartonvolumen berechnen mit Funktion (cube)</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<main>
<div class="container py-5">
<h1>Kartonvolumen berechnen mit Funktion (cube)</h1>
</div>
</main>
<script>
'use strict';
// Konfigurationsvariablen
const BASE_COST_PER_UNIT = 0.7;
const COST_PER_CC = 0.001;
const length = 25;
const width = 30;
const height = 12;
/**
* Funktion zum Berechnen einen Kartonvolumens
*/
const calcCubeVolume = (l, w, h) => {
// cubeVolume = length × width × height
const volume = l * w * h;
return volume;
};
/**
* Funktion zum Berechnen einen Kartonvolumens (Kurzschreibweise)
*/
const calcCubeVolumeShort = (l, w, h) => l * w * h;
/**
* Funktion zum Berechnen der Versandkosten
*/
const calcShippingCost = (volume) => {
// shippingCost = volume × costPerCC + costPerUnit
const cost = volume * COST_PER_CC + BASE_COST_PER_UNIT;
return cost;
};
/**
* Funktion zum Berechnen der Versandkosten (Kurzschreibweise)
*/
const calcShippingCostShort = (volume) => volume * COST_PER_CC + BASE_COST_PER_UNIT;
// const volume = calcCubeVolume(25, 30, 12);
const volume = calcCubeVolume(length, width, height);
// const volumeMiniPackage = calcCubeVolume(10, 5, 5);
console.log(`shipping cost is: $${calcShippingCost(volume).toFixed(2)}`); // => 9.70
</script>
</body>
</html>