I have watched a tutorial wherein he made a square() function that accepts any number as a parameter. The function he made looks like this:
function square(number) {
return number * number;
};
let number = square(2);
console.log(number);
I tried doing the same function by just using the console.log within the function itself, like this:
function square(number) {
console.log(number * number)
};
square(2);
Both code worked but I do not know the difference between the two. Can you please explain to me what is the catch of using either ways? Or better, please provide any reading materials I can use regarding my inquiry.