From f72fcc432159be7e3a4dfdfb65cdb07f2e229197 Mon Sep 17 00:00:00 2001 From: Subliminal Guy <subliminal_kid@posteo.de> Date: Wed, 5 Mar 2025 13:05:51 +0100 Subject: [PATCH] Small Changes --- debugging/calculateSum.js | 18 ++++++------ debugging/debug.js | 19 ++++++------ debugging/recipe.js | 12 ++++---- debugging/username.js | 10 +++---- helper/quizData.js | 61 ++++++++++++++++++++------------------- 5 files changed, 61 insertions(+), 59 deletions(-) diff --git a/debugging/calculateSum.js b/debugging/calculateSum.js index 95aba17..251de6b 100644 --- a/debugging/calculateSum.js +++ b/debugging/calculateSum.js @@ -1,13 +1,13 @@ function calculateSum(numbers) { - let sum = 0; + let sum = 0; - for (let i = 0; i <= numbers.length; i++) { - sum += numbers[i]; - } - - return sum; + for (let i = 0; i <= numbers.length; i++) { + sum += numbers[i]; } + + return sum; +} - const myNumbers = [10, 20, 30, 40, 50]; - const result = calculateSum(myNumbers); - console.log("The sum is:", result); \ No newline at end of file +const myNumbers = [10, 20, 30, 40, 50]; +const result = calculateSum(myNumbers); +console.log("The sum is:", result); \ No newline at end of file diff --git a/debugging/debug.js b/debugging/debug.js index ee25026..55d8fb9 100644 --- a/debugging/debug.js +++ b/debugging/debug.js @@ -1,19 +1,20 @@ function makeUpperCase(name) { -if (typeof name !== "string") { - throw new Error("Name must be a string"); -} -else { - return name.toUpperCase(); -} + if (typeof name !== "string") { + throw new Error("Name must be a string"); + } + else { + return name.toUpperCase(); + } } +let result try { - let result = makeUpperCase(1223); + result = makeUpperCase(1223); } catch (error) { - console.log("Da gab es einen Fehler: ", error.message); + console.log("Da gab es einen Fehler: ", error.message); } - +console.log(result) diff --git a/debugging/recipe.js b/debugging/recipe.js index a4206fe..5535848 100644 --- a/debugging/recipe.js +++ b/debugging/recipe.js @@ -1,11 +1,11 @@ function brewPotion(ingredient1, ingredient2) { - // Ensure both ingredients are provided - if (!ingredient1 || !ingredient2) { - throw new Error("Both ingredients are required."); - } + // Ensure both ingredients are provided + if (!ingredient1 || !ingredient2) { + throw new Error("Both ingredients are required."); + } - // Combine the ingredients with a dash and capitalize them correctly - return ingredient1 + ingredient2 + // Combine the ingredients with a dash and capitalize them correctly + return ingredient1 + ingredient2 } console.log(brewPotion("apple")) \ No newline at end of file diff --git a/debugging/username.js b/debugging/username.js index 4822526..0df4158 100644 --- a/debugging/username.js +++ b/debugging/username.js @@ -1,7 +1,7 @@ function greetUser(name) { - let greeting = "Hello, " + name + "!"; - console.log(greeting); - } + let greeting = "Hello, " + name + "!"; + console.log(greeting); +} - const userName = "Alice"; - greetUser(username); \ No newline at end of file +const userName = "Alice"; +greetUser(username); \ No newline at end of file diff --git a/helper/quizData.js b/helper/quizData.js index f2776bb..134fbd4 100644 --- a/helper/quizData.js +++ b/helper/quizData.js @@ -1,34 +1,35 @@ const questions = [ - { - category: "Geography", - question: "What is the capital of France?", - choices: ["London", "Paris", "Berlin", "Rome"], - answer: "Paris" -}, - { - category: "Movies", - question: "What is the name of the main character in The Matrix?", - choices: ["Neo", "Trinity", "Morpheus", "Cypher"], - answer: "Neo" -}, - { - category: "History", - question: "Who was the first president of the United States?", - choices: ["John Adams", "Thomas Jefferson", "George Washington", "Abraham Lincoln"], - answer: "George Washington" -}, - { - category: "Sports", - question: "Which team won the World Cup in 2018?", - choices: ["France", "Brazil", "Germany", "Italy"], - answer: "France" -} , - { - category: "Science", - question: "What is the chemical symbol for gold?", - choices: ["Au", "Ag", "Pt", "Cu"], - answer: "Au" -} + { + category: "Geography", + question: "What is the capital of France?", + choices: ["London", "Paris", "Berlin", "Rome"], + answer: "Paris" + }, + { + category: "Movies", + question: "What is the name of the main character in The Matrix?", + choices: ["Neo", "Trinity", "Morpheus", "Cypher"], + answer: "Neo" + }, + { + category: "History", + question: "Who was the first president of the United States?", + choices: ["John Adams", "Thomas Jefferson", + "George Washington", "Abraham Lincoln"], + answer: "George Washington" + }, + { + category: "Sports", + question: "Which team won the World Cup in 2018?", + choices: ["France", "Brazil", "Germany", "Italy"], + answer: "France" + } , + { + category: "Science", + question: "What is the chemical symbol for gold?", + choices: ["Au", "Ag", "Pt", "Cu"], + answer: "Au" + } ] export default questions \ No newline at end of file -- GitLab