Problem Statement
What happens if a function does not have a return statement?
Explanation
Every JavaScript function returns something.
If you do not write a return statement, it automatically returns undefined.
This means the function completes its work but does not give any value back to the caller.
Use a return statement when you want to send data out of a function.
Remember, console.log only displays the result — it does not return it.
Code Solution
SolutionRead Only
function add(a, b) {
const sum = a + b;
}
console.log(add(2, 3)); // undefined