Javascript - Function Scope Basics
Code Life
By Pierre Marsaa
Variables Inside a Function
A variable declared inside a function only exists inside that function. Outside, it's as if it never existed:
↗️
Loading editor...
↶
↷
result is a local variable: it belongs to rollDice. Its scope is the function body. This is a good thing: functions don't clutter each other with their temporary variables.
Verify