From d1ba2580852757fbd268d203e95591cd98385349 Mon Sep 17 00:00:00 2001
From: Subliminal Guy <subliminal_kid@posteo.de>
Date: Tue, 18 Feb 2025 13:45:17 +0100
Subject: [PATCH] Add some debugging excercises

---
 debugging/calculateSum.js | 13 +++++++++++++
 debugging/recipe.js       | 11 +++++++++++
 debugging/username.js     |  7 +++++++
 3 files changed, 31 insertions(+)
 create mode 100644 debugging/calculateSum.js
 create mode 100644 debugging/recipe.js
 create mode 100644 debugging/username.js

diff --git a/debugging/calculateSum.js b/debugging/calculateSum.js
new file mode 100644
index 0000000..95aba17
--- /dev/null
+++ b/debugging/calculateSum.js
@@ -0,0 +1,13 @@
+function calculateSum(numbers) {
+    let sum = 0;
+    
+    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
diff --git a/debugging/recipe.js b/debugging/recipe.js
new file mode 100644
index 0000000..a4206fe
--- /dev/null
+++ b/debugging/recipe.js
@@ -0,0 +1,11 @@
+function brewPotion(ingredient1, ingredient2) {
+    // 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
+}
+
+console.log(brewPotion("apple"))
\ No newline at end of file
diff --git a/debugging/username.js b/debugging/username.js
new file mode 100644
index 0000000..4822526
--- /dev/null
+++ b/debugging/username.js
@@ -0,0 +1,7 @@
+function greetUser(name) {
+    let greeting = "Hello, " + name + "!";
+    console.log(greeting);
+  }
+  
+  const userName = "Alice";
+  greetUser(username);
\ No newline at end of file
-- 
GitLab