Use of variable in Julia REPL

Loops have their own scope as of Julia 1.0. I’m a bit puzzled about why the first loop works, but there’s tons of discussion about this, cf this, this, and this. I’ll bet the answer lies somewhere in there, but hopefully someone else can explain.

(Note though that (I don’t think) either of those solutions I linked were implemented)