Skip to content

Commit ebcd8c5

Browse files
Artur GevertArtur Gevert
authored andcommitted
Init repo
0 parents  commit ebcd8c5

File tree

7 files changed

+213
-0
lines changed

7 files changed

+213
-0
lines changed

LearnJS/.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "pwa-chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:5500",
12+
"webRoot": "${workspaceFolder}"
13+
}
14+
]
15+
}

LearnJS/Arrays.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const cars = ["Mazda", "Ford", "BMW", "Mercedes"];
2+
3+
const fib = [1, 1, 2, 3, 5, 8, 13];
4+
5+
cars.push("Renault"); //Output: ["Mazda", "Ford", "BMW", "Mercedes", "Renault"]
6+
cars.unshift("Volvo"); //Output: ["Volvo", "Mazda", "Ford", "BMW", "Mercedes", "Renault"]
7+
8+
const firstCar = cars.shift(); //Output: ["Mazda", "Ford", "BMW", "Mercedes", "Renault"]
9+
const lastCar = cars.pop(); //Output: ["Mazda", "Ford", "BMW", "Mercedes"]
10+
11+
console.log('firstCar', firstCar); //Output: Volvo
12+
console.log('lastCar', lastCar); //Output: Renault
13+
console.log('revers', cars.reverse()); //Output:["Mercedes", "BMW", "Ford", "Mazda"]
14+
15+
cars.includes("Mazda"); //Output: true
16+
cars.includes("Mazda!"); //Output: false
17+
18+
const upperCaseCars = cars.map(car => car.toUpperCase());
19+
console.log('upperCaseCars', upperCaseCars); //Output: ["MERCEDES", "BMW", "FORD", "MAZDA"]
20+
console.log('cars', cars); //Output: ["Mercedes", "BMW", "Ford", "Mazda"]
21+
22+
23+
const pow2 = num => num ** 2;
24+
const pow2Fib = fib.map(pow2);
25+
console.log('pow2Fib', pow2Fib);
26+
27+
//Aufgabe 1 Strign revers
28+
const text = "Hallo, wir lernen JavaScript!"
29+
const reversText = text.split("").reverse().join("");
30+
console.log('reversText', reversText); //Output: !tpircSavaJ nenrel riw ,ollaH
31+
32+
// Array with Objects
33+
const people = [{
34+
name: "Artur",
35+
budget: 12300
36+
},
37+
{
38+
name: "Deni",
39+
budget: 10100
40+
},
41+
{
42+
name: "Michi",
43+
budget: 7800
44+
},
45+
{
46+
name: "Kati",
47+
budget: 1300
48+
}
49+
]
50+
51+
const index = people.findIndex(function (person) {
52+
return person.budget === 7800;
53+
})
54+
console.log('person with 7800', people[index]); //Output: {name: "Michi", budget: 7800}
55+
56+
const person = people.find(function (person) {
57+
return person.budget === 7800;
58+
})
59+
console.log('person with 7800', person); //Output: {name: "Michi", budget: 7800}
60+
61+
//Lambda Funktion
62+
const person2 = people.find(person => person.budget === 7800);
63+
console.log('person with 7800', person); //Output: {name: "Michi", budget: 7800}
64+
65+
66+
//----->>>> REDUCE!!!!
67+
68+
const allBudget = people.reduce(function(acc, person) {
69+
if (person.budget > 10000)
70+
acc += person.budget;
71+
return acc;
72+
}, 0);
73+
console.log('allBudget', allBudget);
74+
75+
const allBudget2 = people
76+
.filter(person => person.budget > 10000)
77+
.reduce(function(acc, person) {
78+
acc += person.budget;
79+
return acc;
80+
}, 0);
81+
console.log('allBudget2', allBudget2);

LearnJS/DynamicString.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function logPerson (s, name, age) {
2+
if (age < 0 ) {
3+
age = "ist noch nicht geboren"
4+
}
5+
//console.log('logPerson', s, name, age);
6+
return `${s[0]}${name}${s[1]}${age}${s[2]}`;
7+
}
8+
9+
const persName = "Artur"
10+
const persAge = 28
11+
const output = logPerson`Name: ${persName}, Alter: ${persAge}!`
12+
13+
console.log('logPerson2 ', output); //Output: Name: Artur, Alter: 28!
14+

LearnJS/Funktionen.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// 1. Funktionen
2+
3+
function greet (name) {
4+
console.log('Hello -s', name);
5+
}
6+
7+
8+
//===============================================================
9+
// 2. Anonyme Funktionen
10+
let counter = 0;
11+
const interval = setInterval(function(){
12+
if (counter === 5) {
13+
clearInterval(interval);
14+
} else {
15+
console.log('counter', ++counter);
16+
}
17+
}, 1000);
18+
19+
20+
//===============================================================
21+
// 3. Pfeilfunktion
22+
// Standart
23+
function greet (name) {
24+
console.log('Hello -', name);
25+
}
26+
27+
//Pfeil
28+
const arrow = (name) => {
29+
console.log('Hello -', name);
30+
}
31+
arrow();
32+
33+
const arrow2 = name => console.log('Hello -', name);
34+
arrow2 ();
35+
36+
37+
const pow2 = num => {
38+
return num ** 2;
39+
}
40+
console.log('sqrt pow2', pow2(5));
41+
42+
43+
//===============================================================
44+
// 4. Parameters by Defaull ECMA (2015)
45+
const sum = (a, b) => a + b;
46+
console.log('sum', sum(41)); //Output: NaN
47+
48+
const sum = (a = 42, b = 1) => a + b;
49+
console.log('sum', sum()); //Output: 43
50+
console.log('sum', sum(41)); //Output: 42
51+
console.log('sum', sum(41, 4)); //Output: 45
52+
53+
54+
// Rest Funktion
55+
function sumAll (...all) {
56+
console.log('sumAll', all);
57+
}
58+
sumAll(1, 2, 3, 4, 5, 6, 7); //Output: [1, 2, 3, 4, 5, 6, 7]
59+
60+
function sumAll2 (...all) {
61+
let result = 0;
62+
for (let num of all) {
63+
result +=num;
64+
}
65+
return result;
66+
}
67+
console.log('sumAll2', sumAll2(1, 2, 3, 4, 5, 6, 7)); //Output: 28
68+
69+
70+
//===============================================================
71+
// 5. Verschlüsse
72+
function makeCounter() {
73+
var counter = 0;
74+
return {
75+
value: function () {
76+
return counter;
77+
},
78+
increment: function () {
79+
counter++;
80+
}
81+
}
82+
}
83+
84+
let a = makeCounter();
85+
let b = makeCounter();
86+
87+
a.increment();
88+
89+
console.log(a.value());//Output: 1
90+
console.log(b.value());//Output: 0

LearnJS/app.js

Whitespace-only changes.

LearnJS/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>LearnJS</title>
7+
</head>
8+
<body>
9+
<h3> JavaStriptease</h3>
10+
<script src="app.js"></script>
11+
12+
</body>
13+
</html>

LearnJS/src/style.css

Whitespace-only changes.

0 commit comments

Comments
 (0)