DEV Community

loading...

Discussion on: How For Loops REALLY work

Collapse
maisonsmd profile image
maisonsmd

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
emnudge profile image
EmNudge Author

Yes, nice catch!

Collapse
devworkssimone profile image
DevWorksSimone

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

Collapse
emnudge profile image
EmNudge Author

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!