diff --git a/debugging/calculateSum.js b/debugging/calculateSum.js new file mode 100644 index 0000000000000000000000000000000000000000..95aba17d828b5344873a3a8c88d1eadf1dd28f86 --- /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 0000000000000000000000000000000000000000..a4206fe2bfefc90f2b41c3d21d6c7dea987d4ac0 --- /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 0000000000000000000000000000000000000000..4822526e152666ed8e902e526ff423ffb547ac83 --- /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