This commit is contained in:
51
06_js-debug/uebungen/u06_error-benutzer/index.html
Normal file
51
06_js-debug/uebungen/u06_error-benutzer/index.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Übung 6: Benutzer erstellen</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.7/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="container py-5">
|
||||
<h1>Übung 6: Benutzer erstellen</h1>
|
||||
</div>
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
function createUser(name, email, age {
|
||||
return {
|
||||
name: name,
|
||||
email: email,
|
||||
age: age,
|
||||
greet: () => {
|
||||
console.log("Hello, " + name + "!");
|
||||
},
|
||||
updateEmail(newEmail) {
|
||||
email = newEmail;
|
||||
console.log("Email updated to " + newEmail);
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
const users = [
|
||||
createUser("Alice", "alice@example.com", 30),
|
||||
createUser("Bob", "bob@example.com", 25),
|
||||
createUser("Charlie", "charlie@example.com", 35),
|
||||
];
|
||||
|
||||
users.forEach(user => {
|
||||
user.greet();
|
||||
user.updateEmail("new_" + user.email);
|
||||
});
|
||||
|
||||
function calculateTotal(a, b, c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
console.log("Total:", calculateTotal(10, 20 30));
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user