07.10.2026 - QuizStart with Search

This commit is contained in:
2026-10-07 17:04:33 +02:00
parent 6973be1069
commit 10b7139ba6
13 changed files with 169 additions and 26 deletions
+25
View File
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>OOP</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<script src="assets/js/04.js" async defer></script>
<script>
</script>
</body>
</html>
+21
View File
@@ -0,0 +1,21 @@
class Student{
constructor(firstName, lastName, age)
{
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
greeting() {
console.log(`Hi, my name is ${this.firstName} ${this.lastName}. I'm ${this.age} years old.`);
};
};
const jonny = new Student("Jonny", "Hilbert", 22);
const lisa = new Student("Lisa", "Lauser", 41);
jonny.greeting();
lisa.greeting();
+13 -13
View File
@@ -29,18 +29,18 @@ function shuffleArray(questionArray)
{
rng = getRandomNumber(questionArray.length);
}
while(newArray.includes(rng));
newArray[i] = rng;
while(newArray.includes(questionArray[rng]));
newArray[i] = questionArray[rng]
}
newArray.forEach((value, index) => {
newArray[index] = questionArray[value];
});
return newArray;
}
function getRandomNumber(maxValue){
let val = Math.floor(Math.random() * maxValue)
if(val >= maxValue)
getRandomNumber(maxValue);
return Math.floor(Math.random() * maxValue);
}
@@ -57,11 +57,11 @@ function resetQuiz(){
function showQuestions() {
questions = shuffleArray(questions);
shuffledQuestions = shuffleArray(questions);
let btn = document.getElementById("resultBtn");
if (currentQuestionIndex >= questions.length) {
if (currentQuestionIndex >= shuffledQuestions.length) {
document.getElementById("quiz-container").hidden = true;
document.getElementById("result").hidden = false;
document.getElementById("score").textContent = score;
@@ -70,18 +70,18 @@ function showQuestions() {
return;
}
let question = questions[currentQuestionIndex];
let currentQuestion = shuffledQuestions[currentQuestionIndex];
document.getElementById("question").textContent = question.question;
document.getElementById("question").textContent = currentQuestion.question;
let answersDiv = document.getElementById("answers");
answersDiv.innerHTML = "";
question.answers.forEach((answer, index ) => {
currentQuestion.answers.forEach((answer, index ) => {
let answerBtn = document.createElement("button");
answerBtn.textContent = answer;
answerBtn.onclick = () => checkAnswer(index, question.correctAnswer);
answerBtn.onclick = () => checkAnswer(index, currentQuestion.correctAnswer);
answersDiv.appendChild(answerBtn);
});