Why do I need to use `return`?

Thank you @mtf.
So, to clarify your example.

I know there is more to this, but in basic terms:

let number = 5; variable is outside of the { } so it is global scope

function calc(){
return number;
}

console.log(calc());

function calc() {
let number = 5; variable is inside the { }— local scope
return number;
}

console.log(calc());

1 Like

That is correct. In the second example above, number is not accessible from global scope.

1 Like

This was also my thought. I get the logic of how the code is computed now, but still in limbo as to how each would be more beneficial than another in a practical sense.