Q:

printing the result of the function to the console.

var square = function(x){
   return x*x;
}
square(10);//100 

var square = function(x){
  var total = x*x;
  console.log(total);
}
square(10);//second way(probably wrong)

I was reviewing what I once wrote when passing the JS-track on codecademy.com. 
The task is incredibly simple - write a function that just squares a number and prints it in the console.
I did it the second way (using total variable inside the function block).
Now I would do it the first way. Both seem to work. 
But is the second one really correct? 

A:

The second one is still correct if you want it printed to the console. In a real-world situation, you'd want the result returned to the calling function so it can do other things with the value and then it would fail, since your function does not return anything.

