Why do we have to type var again inside the function when we already have declared the same globally?
When you declare a variable in a function, it’s what the function will use instead of the global one.
They are two different variables. You define a variable if you need it.