Write a function called multiply that takes two numbers and returns their product. Then write a simple console assertion to test it with the values 4 and 5.
Testing and debugging are essential for building reliable JavaScript applications.
The console
object helps track what's happening in your code.
Examples:
console.log("Debug message");
console.error("Error message");
console.warn("Warning message");
Modern browsers let you pause execution and inspect variables using developer tools.
Automated tests ensure your code works as expected and prevent future bugs.
function add(a, b) {
return a + b;
}
console.assert(add(2, 3) === 5, "Add function failed");