DEV Community

Discussion on: How For Loops REALLY work

Collapse
 
maisonsmd profile image
maisonsmd • Edited

Nice explaination, but I noticed a typo in this snippet, which confused me for a while:

var i = 8;
function myFunc() {
  console.log(i);
}

(function(){
  var i = 4;
  myFunc(); // > 0
})()

I think you did want to initialize i = 0 in the first line.

Collapse
 
devworkssimone profile image
DevWorksSimone • Edited

Please tell me its a typo cause I stop there thinking I didnt get anything

Collapse
 
emnudge profile image
EmNudge • Edited

I updated the post as soon as he sent this comment. It was in fact a typo and it should be fixed. My deepest apologies.

Thread Thread
 
devworkssimone profile image
DevWorksSimone

Thanks, I was worried my english needed an improvement!

Collapse
 
emnudge profile image
EmNudge

Yes, nice catch!