console.log()
is a function. And a function is always going to return some value back to the caller. If a return value is not specified, then the function will return back undefined, as in console.log()
.
For example, copy and paste the below code in the console:
function isThisWorking(input) {
console.log("Printing: isThisWorking was called and " + input + " was passed in as an argument.");
return "I am returning this string!";
}
isThisWorking(3);
So, isThisWorking
function will return back "I am returning this string!" in the console, because that's what the function is returning.
But, If we removed the return, it will return back undefined:
function isThisWorking(input) {
console.log("Printing: isThisWorking was called and " + input + " was passed in as an argument.");
}
isThisWorking(3);
Top comments (0)