Function Intro #7 explanation


Hi, guys. I don't actually need help, that is to say I'm not stuck; what I'm looking for is a bit of explanation. I don't understand how the Return keyword, at least in this exercise functions any differently than just running a function such as

var numMultiplier = function (number) {
var numMultiplier = number * 2;



console.log outputs from anywhere in the program to the console screen. What return does is that it outputs from the scope of the function to the scope that is calling so it is a lot more versatile and can do more than just printing to the screen.


var timesTwo = function(x){

just prints the result to the screen. But for example:

var timesTwo2 = function(x){
  return x*2;

let's you use the function call as if it is the value that is returned e.g.

var result = timesTwo2(3)+timesTwo2(4) -> 6+8 = 14

which in the end could be printed to the console as well by:
console.log(result) but which could also be used further in the program whereas console.log would just output it.


Ok, that makes sense, that you can use it to recall values later on. I thought it was just answer print command. Thank you!