Skip to content

Commit 9432ba7

Browse files
authored
Update Exercise_2025-02-27_TypeScript.md
1 parent 6a429af commit 9432ba7

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Material/Notes/Exercises/Exercise_2025-02-27_TypeScript.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,32 @@ function getDriversWithPlates(people) {
5353
5454
for (let person of people) {
5555
const initials = person.name
56-
.split(" ")
56+
.split(' ')
5757
.map((n) => n[0])
58-
.join("");
58+
.join('');
5959
const birthDate = new Date(person.birthDate);
6060
const birthYear = birthDate.getFullYear();
61-
const birthMonth = (birthDate.getMonth() + 1).toString().padStart(2, "0");
62-
const birthDay = birthDate.getDate().toString().padStart(2, "0");
61+
const birthMonth = (birthDate.getMonth() + 1).toString().padStart(2, '0');
62+
const birthDay = birthDate.getDate().toString().padStart(2, '0');
6363
6464
// Standard-Kennzeichenoptionen
6565
let licensePlate1 = `KA-${initials}-${birthDay}${birthMonth}`;
6666
let licensePlate2 = `KA-${initials}-${birthYear}`;
6767

6868
// H- oder E-Kennzeichen hinzufügen, falls angegeben
69-
if (person.carType === "oldtimer") {
70-
licensePlate1 += "H";
71-
licensePlate2 += "H";
72-
} else if (person.carType === "electric") {
73-
licensePlate1 += "E";
74-
licensePlate2 += "E";
69+
if (person.carType === 'oldtimer') {
70+
licensePlate1 += 'H';
71+
licensePlate2 += 'H';
72+
} else if (person.carType === 'electric') {
73+
licensePlate1 += 'E';
74+
licensePlate2 += 'E';
7575
}
7676

77-
const age = (new Date().getFullYear() - birthYear) -
78-
((birthMonth < (new Date().getMonth()+1))
79-
|| ((birthMonth == (new Date().getMonth()+1) && new Date().getDate() <= birthDay))
80-
? 0 : 1 )
81-
77+
const age =
78+
new Date().getFullYear() -
79+
birthYear -
80+
(birthMonth < new Date().getMonth() + 1
81+
|| (birthMonth == new Date().getMonth() + 1 && new Date().getDate() <= birthDay) ? 0 : 1);
8282

8383
if (age >= 18) {
8484
drivers.push({
@@ -93,9 +93,9 @@ function getDriversWithPlates(people) {
9393

9494
// Beispielnutzung
9595
const people = [
96-
{ name: "Max Mustermann", birthDate: "2003-05-15", carType: "oldtimer" },
97-
{ name: "Lisa Schmidt", birthDate: "2010-11-22" },
98-
{ name: "Hans Müller", birthDate: "1990-07-10", carType: "electric" },
96+
{ name: 'Max Mustermann', birthDate: '2003-05-15', carType: 'oldtimer' },
97+
{ name: 'Lisa Schmidt', birthDate: '2010-11-22' },
98+
{ name: 'Hans Müller', birthDate: '1990-07-10', carType: 'electric' },
9999
];
100100

101101
console.log(getDriversWithPlates(people));

0 commit comments

Comments
 (0)