Skip to content
Snippets Groups Projects
Commit f72fcc43 authored by Subliminal Guy's avatar Subliminal Guy
Browse files

Small Changes

parent 25e29d7f
No related branches found
No related tags found
No related merge requests found
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
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)
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
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment