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

Add some debugging excercises

parent 43419d7c
No related branches found
No related tags found
No related merge requests found
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
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
function greetUser(name) {
let greeting = "Hello, " + name + "!";
console.log(greeting);
}
const userName = "Alice";
greetUser(username);
\ 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