question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexplained scopes in ES6: Compare Scopes of the var and let Keywords

See original GitHub issue

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/es6/compare-scopes-of-the-var-and-let-keywords In this lesson, “block scope” is not explained, at least not so clear as what https://www.w3schools.com/js/js_let.asp does.

The sentence

i is not defined because it was not declared in the global scope

is especially confusing because if i is declared with var in the same situation, the console will not return “i is not defined”.

The points are:

  1. What kinds of scope exist?
  2. What scopes can var and let have?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
moT01commented, Apr 22, 2020

Any suggestions @GrimPixel?

I think the challenge as a whole could use some simplification. The code examples feel more complicated than they need to be to illustrate the concept. The description is quite long as well. But that’s a whole rewrite of the challenge. I’m not sure it’s worth it.

0reactions
ieahleencommented, Oct 17, 2020

oh, sorry, it seems the version I remember was changed before this then

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compare Scopes of the var and let Keywords - GitHub
Be certain not to use the var keyword anywhere in your code. This exercise is designed to illustrate the difference between how var...
Read more >
ES6: Compare Scopes of the var and let Keywords - JavaScript
Here's the code I have written function checkScope() { "use strict"; let i = "function scope"; if (true) { i = "block scope"; ......
Read more >
Variable scope, closure - The Modern JavaScript Tutorial
That's because functions aren't variables. You can however, assign a function to a variable declared with let, const or var. But that is...
Read more >
ES6 Tutorial - #2 Let vs. Const, Scope, and Hoisting - Video Explode
00:01:34let us close that and let's go back to 00:01:35latin cons well if you've been using 00:01:38javascript you've probably seen the VAR 00:01:39keyword...
Read more >
Why predeclared variables? - #17 by RFluff - Development - scsynth
As much as the edge cases of hoisting are strange, changing scope details ... they introduced a new let keyword in ES6 to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found