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.

This exercise does not make sense.

See original GitHub issue

Challenge 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…

  1. 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.
  2. 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.
  3. 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

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
staffordrcommented, Feb 15, 2017

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.

1reaction
tomosutocommented, Nov 13, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

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