This commit is contained in:
@@ -33,11 +33,41 @@
|
|||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// const username = prompt('Wilkommen. Wie heißen Sie?');
|
const QUESTION_1 = 'Which Operators has the higher priority: * or + ?';
|
||||||
|
const SOLUTION_1 = '*';
|
||||||
|
|
||||||
/*
|
const QUESTION_2 = "What's the German word for if";
|
||||||
TODO: Your Code
|
const SOLUTION_2A = 'wenn';
|
||||||
*/
|
const SOLUTION_2B = 'falls';
|
||||||
|
|
||||||
|
// 1.Als ersten Schritt fragen Sie den Spieler nach seinem Namen, speichern diesen in eine Variable und begrüßen ihn mittels einer Alert-Box.
|
||||||
|
const name = prompt('Wie heißen Sie?');
|
||||||
|
alert(`Hallo ${name}`);
|
||||||
|
// 2.Stellen Sie dem Spieler die Frage, ob er sich fit genug fühlt, um gegen das dunkle JavaScript anzutreten. Es ist sinnvoll, bei der Frage die Antwortmöglichkeiten anzugeben.
|
||||||
|
const fitness = prompt('Fühlen Sie sich fit genug, um gegen das dunkle JavaScript anzutreten. ja oder nein?');
|
||||||
|
if (fitness === 'ja') {
|
||||||
|
alert('Das Spiel startet! Gib alles !');
|
||||||
|
let answer = prompt(QUESTION_1);
|
||||||
|
if (answer === SOLUTION_1) {
|
||||||
|
alert('Gratulation');
|
||||||
|
let answer = prompt(QUESTION_2);
|
||||||
|
if (answer === SOLUTION_2A || answer === SOLUTION_2B) {
|
||||||
|
alert('Gratulation');
|
||||||
|
let answer = prompt('Now, please enter a string with a length between 8 and 15 characters…');
|
||||||
|
if (answer.length >= 8 && answer.length <= 15) {
|
||||||
|
alert('Gratulation');
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else if (fitness === 'nein') {
|
||||||
|
alert('Go Home');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -34,10 +34,32 @@
|
|||||||
// Aufgabe
|
// Aufgabe
|
||||||
const firstName = prompt('Wilkommen. Wie heißen Sie mit Vornamen?');
|
const firstName = prompt('Wilkommen. Wie heißen Sie mit Vornamen?');
|
||||||
const lastName = prompt('Und mit Nachnamen?');
|
const lastName = prompt('Und mit Nachnamen?');
|
||||||
|
const age = Number(prompt('Wie alt sind Sie?'));
|
||||||
|
const favoriteHotDrink = prompt('Und was ist ihr liebstes Heißgetränk? tee (t) oder kaffee (c)?');
|
||||||
|
|
||||||
const age = Number('Wie alt sind Sie?');
|
let errorMessage = '';
|
||||||
|
|
||||||
const favoriteHotDrink = prompt('Und was ist ihr liebstes Heißgetränk? (tee | kaffee)');
|
if (lastName.length < 2 || lastName.length > 100) {
|
||||||
|
errorMessage += 'name ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstName.length < 2 || firstName.length > 100) {
|
||||||
|
errorMessage += 'first name ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (favoriteHotDrink !== 'c' && favoriteHotDrink !== 't') {
|
||||||
|
errorMessage += 'favoriteHotDrink ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNaN(age) || age >= 150) {
|
||||||
|
errorMessage += 'age ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorMessage === '') {
|
||||||
|
console.log('OK!');
|
||||||
|
} else {
|
||||||
|
console.log(`KO! The following entries are invalid: ${errorMessage}`);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -45,10 +45,21 @@
|
|||||||
const inputEl = document.querySelector('.input-year');
|
const inputEl = document.querySelector('.input-year');
|
||||||
const outputEl = document.querySelector('.output');
|
const outputEl = document.querySelector('.output');
|
||||||
|
|
||||||
|
const isLeapYear = (year) => {
|
||||||
|
const checkOne = year % 400 === 0;
|
||||||
|
const checkTwo = year % 100 !== 0 && year % 4 === 0;
|
||||||
|
return checkOne || checkTwo;
|
||||||
|
};
|
||||||
|
|
||||||
|
let output = '';
|
||||||
|
|
||||||
inputEl.addEventListener('input', (e) => {
|
inputEl.addEventListener('input', (e) => {
|
||||||
const val = e.currentTarget.value;
|
const val = e.currentTarget.value;
|
||||||
|
|
||||||
// TODO: check if it is a leap year or not.
|
output = isLeapYear(val) ? `${val} ist ein Schaltjahr` : `${val} ist KEIN Schaltjahr`;
|
||||||
|
|
||||||
|
console.log(output);
|
||||||
|
outputEl.textContent = output;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
const text =
|
const text =
|
||||||
'Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Nadel Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen';
|
'Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Nadel Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen Heuhaufen';
|
||||||
|
|
||||||
|
outputEl.textContent = text.indexOf('Nadel');
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -27,6 +27,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const name = ' Ladislaus Coolio Jones '.trim();
|
const name = ' Ladislaus Coolio Jones '.trim();
|
||||||
|
const firstName = name.substring(0, name.indexOf(' '));
|
||||||
|
const lastName = name.substring(name.lastIndexOf(' ') + 1);
|
||||||
|
|
||||||
|
console.log(firstName); // => 'Ladislaus'
|
||||||
|
console.log(lastName); // => 'Jones'
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -25,6 +25,11 @@
|
|||||||
const outputElement = document.querySelector('.output');
|
const outputElement = document.querySelector('.output');
|
||||||
|
|
||||||
const name = 'Heribert Gold '.trim();
|
const name = 'Heribert Gold '.trim();
|
||||||
|
const firstName = name.substring(0, name.indexOf(' '));
|
||||||
|
const lastName = name.substring(name.lastIndexOf(' ') + 1);
|
||||||
|
|
||||||
|
console.log(firstName); // => 'Heribert'
|
||||||
|
console.log(lastName); // => 'Gold'
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -26,7 +26,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const outputEl = document.querySelector('.output');
|
const outputEl = document.querySelector('.output');
|
||||||
|
|
||||||
const name = 'Ladislaus Jones'.trim();
|
const fullName = 'Ladislaus Jones'.trim();
|
||||||
|
const firstNameInitial = fullName.charAt(0);
|
||||||
|
const lastName = fullName.slice(fullName.lastIndexOf(' ') + 1);
|
||||||
|
|
||||||
|
outputEl.textContent = `${lastName}, ${firstNameInitial}.`;
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -26,12 +26,20 @@
|
|||||||
<li>007 => 007</li>
|
<li>007 => 007</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="output alert alert-secondary my-3"></div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let itemNumber = '123';
|
const outputEl = document.querySelector('.output');
|
||||||
|
|
||||||
|
let itemNumber = prompt('Your itemNumber?');
|
||||||
|
|
||||||
|
let correctedItemNumber = itemNumber.charAt(0) === '0' ? itemNumber : '0' + itemNumber;
|
||||||
|
|
||||||
|
console.log(correctedItemNumber);
|
||||||
|
outputEl.textContent = correctedItemNumber;
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -35,16 +35,47 @@
|
|||||||
<script>
|
<script>
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// const QUESTION_1 = 'es geht los! Sag mir mal, welcher Operator die höhere Priorität hat: * oder + ?';
|
const QUESTION_1 = 'Which Operators has the higher priority: * or + ?';
|
||||||
// const SOLUTION_1 = '*';
|
const SOLUTION_1 = '*';
|
||||||
|
|
||||||
// const QUESTION_2 = 'Was ist das deutsche Wort für if?';
|
const QUESTION_2 = "What's the German word for if";
|
||||||
// const SOLUTION_2A = 'falls';
|
const SOLUTION_2A = 'wenn';
|
||||||
// const SOLUTION_2B = 'wenn';
|
const SOLUTION_2B = 'falls';
|
||||||
|
|
||||||
// const QUESTION_3 = 'Jetzt gib bitte einen String mit einer Länge von 8 bis 15 Zeichen ein';
|
const QUESTION_3 = 'Now, please enter a string with a length between 8 and 15 characters…';
|
||||||
// const SOLUTION_3A = 8;
|
const SOLUTION_3A = 8;
|
||||||
// const SOLUTION_3B = 15;
|
const SOLUTION_3B = 15;
|
||||||
|
|
||||||
|
// 1.Als ersten Schritt fragen Sie den Spieler nach seinem Namen, speichern diesen in eine Variable und begrüßen ihn mittels einer Alert-Box.
|
||||||
|
const name = prompt('Wie heißen Sie?');
|
||||||
|
alert(`Hallo ${name}`);
|
||||||
|
// 2.Stellen Sie dem Spieler die Frage, ob er sich fit genug fühlt, um gegen das dunkle JavaScript anzutreten. Es ist sinnvoll, bei der Frage die Antwortmöglichkeiten anzugeben.
|
||||||
|
const fitness = prompt('Fühlen Sie sich fit genug, um gegen das dunkle JavaScript anzutreten. ja oder nein?')
|
||||||
|
.toLowerCase()
|
||||||
|
.trim();
|
||||||
|
if (fitness === 'ja' || fitness === 'j') {
|
||||||
|
alert('Das Spiel startet! Gib alles !');
|
||||||
|
let answer = prompt(QUESTION_1);
|
||||||
|
if (answer === SOLUTION_1) {
|
||||||
|
alert('Gratulation');
|
||||||
|
let answer = prompt(QUESTION_2).toLowerCase().trim();
|
||||||
|
if (answer === SOLUTION_2A || answer === SOLUTION_2B) {
|
||||||
|
alert('Gratulation');
|
||||||
|
let answer = prompt(QUESTION_3);
|
||||||
|
if (answer.length >= SOLUTION_3A && answer.length <= SOLUTION_3B) {
|
||||||
|
alert('Gratulation');
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('Das war falsch!');
|
||||||
|
}
|
||||||
|
} else if (fitness === 'nein') {
|
||||||
|
alert('Go Home');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
@@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
const outputEl = document.querySelector('.output');
|
const outputEl = document.querySelector('.output');
|
||||||
|
|
||||||
/*
|
const logName = () => {
|
||||||
TODO: Schreibe eine Funktion, die deinen Namen in der Konsole ausgibt.
|
console.log('Philippe Torrel');
|
||||||
*/
|
};
|
||||||
|
|
||||||
|
logName();
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -33,6 +33,14 @@
|
|||||||
console.log(zahl4); // => '10.5'
|
console.log(zahl4); // => '10.5'
|
||||||
|
|
||||||
const outputEl = document.querySelector('.output') || console.warn('Element existiert nicht');
|
const outputEl = document.querySelector('.output') || console.warn('Element existiert nicht');
|
||||||
|
|
||||||
|
// const slider = (el = null, opts) => {
|
||||||
|
// const selector = el || document.querySelector('.slider');
|
||||||
|
|
||||||
|
// // more logic
|
||||||
|
// };
|
||||||
|
|
||||||
|
// slider(document.querySelector('.my-slider'));
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
// String - Methode str.indexOf('searchValue' [, position]) - optionaler Parameter
|
// String - Methode str.indexOf('searchValue' [, position]) - optionaler Parameter
|
||||||
|
|
||||||
console.log('name.indexOf("a", 2): ', name.indexOf('a', 2)); // => 6
|
console.log('name.indexOf("a", 2): ', name.indexOf('a', 2)); // => 6
|
||||||
|
console.log('lorem ipsum'.indexOf('m', 5)); // => 10
|
||||||
|
|
||||||
// Strign - Methode str.lastIndexOf('searchValue')
|
// Strign - Methode str.lastIndexOf('searchValue')
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<div class="container py-5">
|
<div class="container py-5">
|
||||||
<h1>
|
<h1>
|
||||||
<a href="https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/substr"
|
<a href="https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/String/substr"
|
||||||
>String.substr(startIndex, length) DEPREACATED</a
|
>String.substr(startIndex, length) DEPRECATED</a
|
||||||
>
|
>
|
||||||
</h1>
|
</h1>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
// String - Methode str.charAt(index)
|
// String - Methode str.charAt(index)
|
||||||
|
|
||||||
console.log('Lisa Simpos'.charAt(0)); // => 'L'
|
console.log('Lisa Simpos'.charAt(0)); // => 'L'
|
||||||
console.log('Lisa Simpon'.charAt(5)); // => 'S'
|
console.log('Lisa Simpons'.charAt(5)); // => 'S'
|
||||||
|
|
||||||
// Default-Wert bei keiner Angabe ist 0
|
// Default-Wert bei keiner Angabe ist 0
|
||||||
console.log('Lisa Simpos'.charAt()); // => 'L'
|
console.log('Lisa Simpos'.charAt()); // => 'L'
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
// str.replaceAll - seit Juni 2021
|
// str.replaceAll - seit Juni 2021
|
||||||
outputEl.textContent = productDescription.replaceAll(productName, newProductName);
|
outputEl.textContent = productDescription.replaceAll(productName, newProductName);
|
||||||
|
|
||||||
|
console.log('I love JS. JS is the best language'.replace('JS', 'TS'));
|
||||||
|
// => 'I love TS. JS is the best language'
|
||||||
|
|
||||||
console.log('I love JS. JS is the best language'.replace(/JS/g, 'TS'));
|
console.log('I love JS. JS is the best language'.replace(/JS/g, 'TS'));
|
||||||
// => 'I love TS. TS is the best language'
|
// => 'I love TS. TS is the best language'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user