I understand why the following alert() returns "blue". 

```
var color = "blue";
function getcolor () {
return color;
color = "red";
}
alert(getcolor());

```

If i'm not incorrect, the function stops executing after its return statement, preventing the global "color" variable from being overwritten.

But why, if we change the function's definition to that below, does the alert() return "undefined"?

```
var color = “blue”;
function getcolor () {
return color;
var color = “red”;
}

alert(getcolor());

```

I expected that the getcolor() function would exit after the return statement, as before, and return the value of the global color variable "blue".