This exercise does not make sense.
See original GitHub issueChallenge Local Scope and Functions has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
function myLocalScope() {
myVar = 'use strict';
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
This Challenge asks the user to make a variable…
- In it’s initialized state there is the line “use strict”; So the assumption I made was that the instruction is to assign the string to myVar.
- Fine. that’s what I did, then it looks like the goal is to run it, see it fail (because the last line is a call to print variable “myVar” which will not work because it is only a local variable within the function.
- Then the “commented out” instructions say to comment that line out. My expectation would be that then the illegal call would no longer be there and the challenge would pass! But this is not what happens!!! Instead it just gives 2 errors: 'no global variable “myVar” ’ What does that Mean??? Nowhere in the commented out instructions, or Challenge instructions does it ask to make a global variable!!!
Note that even if I DO create a global variable … the challenge does not pass either!
So what is required to make this challenge pass? Perhaps the instructions for this challenge are not clearly stated?
c
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
We make exercise way too complicated. Here's how to get it ...
1) If you're not exercising regularly, doing any activity will help dog talk ... Don't think about jumping from the couch into a...
Read more >Why Exercise Is Wise (for Teens) - Nemours KidsHealth
Exercising regularly can help prevent weight gain, type 2 diabetes, heart disease, and high blood pressure. Bone-strengthening exercise — like jumping, running ...
Read more >How Painful Should Your Workout Be? - The New York Times
Every strenuous exercise involves some mixture of suffering and pleasure. The key to sticking with it is getting the balance right.
Read more >7 Common Workout Mistakes To Avoid | Henry Ford Health
What to do: Resistance training doesn't necessarily mean lifting weights. Yoga, swimming, and body weight exercises — lunges, push-ups and ...
Read more >7 Exercise Myths That Can Derail Your Weight-Loss Goals
Exercise Myths – #1: The more you sweat, the more pounds you will drop. Fact: Weight loss is not about sweating. It's about...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just want to add that the previous challenge makes it even more confusing because it doesn’t specify to declare the variable with the “var” keyword", explicitly stating that when anytime you declare a variable with “var”, it will have a global scope.
I also had to refresh to get this challenge to pass without any change to the code. This one definitely needs updating, and maybe consider explaining when to use “var” and when not to in a way that isn’t utterly confusing.
I’ve had the same problem as Jeff. It worked when I performed a hard refresh in the browser so I’m guessing it is the cache issue.