Global Scope and Functions on beta.freecodecamp
See original GitHub issueAnswer is not accepted on the Beta Freecodecamp. “Do not declare oopsGlobal using the var keyword” is the only issue showing up.
Challenge Global Scope and Functions has an issue.
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/602.3.12 (KHTML, like Gecko) Version/10.0.2 Safari/602.3.12
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// Declare your variable here
var myGlobal = 10;
function fun1() {
// Assign 5 to oopsGlobal Here
oopsGlobal = 5;
}
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (8 by maintainers)
Top Results From Across the Web
freeCodeCamp Challenge Guide: Global Scope and Functions
Global Scope and Functions Hints Hint 1 The scope of a variable is its visibility; where in the code is the function available?...
Read more >Free Code Camp - Basic Javascript Flashcards | Quizlet
We tell JavaScript to create or declare a variable by putting the keyword var ... Variables which are defined outside of a function...
Read more >Generate Random Whole Numbers within a Range - JavaScript
Freecodecamp Basic JavaScript: Generate Random Whole Numbers within a Range ... declare variables(old way of declaring variables), Function or global scope.
Read more >define global and local scope? - Codecademy
In the picture below, the scope of the local variable is highlighted blue – it's the function where that var was defined. Any...
Read more >FreeCodeCamp/HelpBackEnd - Gitter
It would be very bad programming practice to make a variable outside of the scope of a function, that is ONLY used WITHIN...
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
Needs a bot more creative solution though, will take a look when I can, but keeping open for others to pitch in.
I found the source of the issue!
var oopsGlobal;
is in the head here. This is now an issue because the head and tail are now included in the tests (https://github.com/freeCodeCamp/freeCodeCamp/issues/10258)Removing the definition from the head fixes the browser tests, but it breaks the CI tests.
@freeCodeCamp/moderators What would work, is moving
var oopsGlobal;
to the beginning of thesolution
, although that seems a bit hacky to me. Should I go through with that?