This commit is contained in:
Philippe Torrel
2026-06-19 10:33:44 +02:00
parent 91406bd7f1
commit 7cbd3bef3b
8 changed files with 84 additions and 38 deletions

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -23,68 +23,68 @@
<tbody>
<tr>
<td>'1.5' * 2</td>
<td>-</td>
<td>-</td>
<td>3</td>
<td>number</td>
</tr>
<tr>
<td>'1,5' * 2</td>
<td>-</td>
<td>-</td>
<td>NaN</td>
<td>number</td>
</tr>
<tr>
<td>'1.5' + 2</td>
<td>-</td>
<td>-</td>
<td>'1.52'</td>
<td>string</td>
</tr>
<tr>
<td>Number('1.5') * 2</td>
<td>-</td>
<td>-</td>
<td>3</td>
<td>number</td>
</tr>
<tr>
<td>Number('1,5') * 2</td>
<td>-</td>
<td>-</td>
<td>NaN</td>
<td>number</td>
</tr>
<tr>
<td>Number('3 Tage') * 7</td>
<td>-</td>
<td>-</td>
<td>NaN</td>
<td>number</td>
</tr>
<tr>
<td>Number('Seite 20') + 5</td>
<td>-</td>
<td>-</td>
<td>NaN</td>
<td>number</td>
</tr>
<tr>
<td>'9,2' + Number('11.7')</td>
<td>-</td>
<td>-</td>
<td>'9,211.7'</td>
<td>string</td>
</tr>
<tr>
<td>(NaN - 2) * (4 / 2)</td>
<td>-</td>
<td>-</td>
<td>NaN</td>
<td>number</td>
</tr>
<tr>
<td>alert(Number(17 / 2 + 1.3))</td>
<td>-</td>
<td>-</td>
<td>undefined</td>
<td>'undefined'</td>
</tr>
<tr>
<td>console.log(Number(17 / 2 + 1.3))</td>
<td>-</td>
<td>-</td>
<td>undefined</td>
<td>'undefined'</td>
</tr>
<tr>
<td>typeof 12.25</td>
<td>-</td>
<td>-</td>
<td>'number'</td>
<td>string</td>
</tr>
<tr>
<td>typeof typeof 12.25</td>
<td>-</td>
<td>-</td>
<td>'string'</td>
<td>string</td>
</tr>
</tbody>
</table>
@@ -92,6 +92,11 @@
</main>
<script>
'use strict';
// const result = alert('hello');
// const result2 = console.log('Ergebnis: ', result);
// console.log(result, result2);
</script>
</body>
</html>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -42,9 +42,22 @@
</main>
<script>
'use strict';
//const tankGroesse = console.prompt('Wie groß ist Ihr Tank in liter?');
const outputAEl = document.querySelector('.output-a');
const outputBEl = document.querySelector('.output-b');
const streckeKm = Number(prompt('gefahrene Stecke in km'));
const benzinL = Number(prompt('Benzinverbrauch in l'));
const tankGroesse = Number(prompt('Tankgröße in l'));
const verbrauchkm = (benzinL / streckeKm) * 100;
////////////////
const maxReichweite = (tankGroesse * streckeKm) / benzinL;
outputAEl.textContent = `${verbrauchkm.toFixed(1)} l/100km.`;
outputBEl.textContent = `Die maximale Reichweite beträgt ${Math.round(maxReichweite)}km`;
</script>
</body>
</html>

View File

@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
@@ -22,6 +22,22 @@
'use strict';
const outputEl = document.querySelector('.output');
// Wie viele Minuten und Restsekunden haben 2000 Sekunden? Verwende console.log für die Ausgabe.
const minuten = 60;
const gesamtSekunden = 2000;
const sekProMinute = Math.round(gesamtSekunden / minuten);
const restsekunden = Math.round(gesamtSekunden % 60);
console.log(sekProMinute);
console.log(restsekunden);
const text = `2000 Sekunden sind ${sekProMinute} Minuten und ${restsekunden} Sekunden. ${sekProMinute}:${restsekunden} (mm:ss)`;
console.log(text);
outputEl.textContent = text;
outputEl.innerHTML = text.replaceAll('\n', '');
</script>
</body>
</html>

View File

@@ -16,7 +16,7 @@
overflow: hidden;
}
.lotto-number {
.lotto-ball {
width: 50px;
height: 50px;
border-radius: 50%;
@@ -28,7 +28,7 @@
background: radial-gradient(circle, rgba(242, 242, 242, 1) 0%, rgba(130, 130, 130, 1) 93%);
box-shadow: 0px 3px 10px rgba(0, 0, 0, 0.2);
}
.lotto-number span {
.lotto-number {
font-weight: bolder;
}
</style>
@@ -36,7 +36,7 @@
<body>
<main>
<div class="container py-5">
<div class="alert alert-primary animate__animated animate__shakeY animate__infinite">
<div class="alert alert-primary">
<h2>Übung 18: Lotto oder der »49-Seiten Würfel«</h2>
<p>
Für Zufallszahlen von eins bis sechs ist ein Würfel wirklich praktisch — und sinnvoll. Für alle anderen
@@ -58,6 +58,11 @@
const outputEl = document.querySelector('.output');
const lottoNumberEl = document.querySelector('.lotto-number');
// Lottozahl ermitteln (von 1-49)
const lottoNumber = Math.floor(Math.random() * 49) + 1;
lottoNumberEl.textContent = lottoNumber;
</script>
</body>
</html>