This commit is contained in:
Philippe Torrel
2026-09-09 10:51:04 +02:00
parent 627096ba41
commit 84fc2efe6f
9 changed files with 212 additions and 5 deletions

View File

@@ -0,0 +1,76 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Nur ein bisschen rechnen …</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>Nur ein bisschen rechnen …</h1>
<table id="calcIt" class="table table-striped">
<thead class="table-dark">
<tr>
<th>Ausdruck</th>
<th>Rückgabewert</th>
</tr>
</thead>
<tbody>
<tr>
<td>3 + 4</td>
<td></td>
</tr>
<tr>
<td>3 * 12</td>
<td></td>
</tr>
<tr>
<td>25 + 12</td>
<td></td>
</tr>
<tr>
<td>(12 - 3) / 3</td>
<td></td>
</tr>
<tr>
<td>12 % 3</td>
<td></td>
</tr>
<tr>
<td>12 * (44 / 11) / 3 + 67</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</main>
<script>
'use strict';
// document
// .getElementById('calcIt')
// .querySelectorAll('tbody tr')
// .forEach((oRow) => {
// oRow.children[1].innerText = eval(oRow.children[0].innerText);
// });
const aCalc = [
3 + 4, //
3 * 12,
25 + 12,
(12 - 3) / 3,
12 % 3,
(12 * (44 / 11)) / 3 + 67,
];
const tableEl = document.getElementById('calcIt');
const oRows = tableEl.querySelectorAll('tbody > tr');
aCalc.forEach((nResult, idx) => {
oRows[idx].children[1].textContent = nResult;
});
</script>
</body>
</html>