Loading workspace environment...
Decode error messages and master the art of finding and fixing bugs.
function safeDivide(a, b) {
if (b === 0) {
return "Error: Cannot divide by zero!";
}
return a / b;
}
console.log("10 / 2 =", safeDivide(10, 2));
console.log("10 / 0 =", safeDivide(10, 0));10 / 2 = 5
10 / 0 = Error: Cannot divide by zero!if (b === 0)Guards against division by zero before doing the math.// Panicking and randomly changing code without reading the error message// Step 1: Read the error name
// Step 2: Look at the line number mentioned
// Step 3: Check variable types at that lineArchitectural Explanation: Error messages are clues specifically written to tell you what went wrong.
The following starter code has a bug: it tries to call a variable that was misspelled. Fix the typo so it logs "Welcome, Alex!".