In JavaScript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means, they can be seen everywhere in your JavaScript code.
Variables which are used without the <code>var</code> keyword are automatically created in the <code>global</code> scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with <code>var</code>.
</section>
## Instructions
<sectionid='instructions'>
Using <code>var</code>, declare a <code>global</code> variable <code>myGlobal</code> outside of any function. Initialize it with a value of <code>10</code>.
Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</code><strong><em>without</em></strong> using the <code>var</code> keyword.
testString: 'assert(typeof myGlobal != "undefined", ''<code>myGlobal</code> should be defined'');'
- text: <code>myGlobal</code> should have a value of <code>10</code>
testString: 'assert(myGlobal === 10, ''<code>myGlobal</code> should have a value of <code>10</code>'');'
- text: <code>myGlobal</code> should be declared using the <code>var</code> keyword
testString: 'assert(/var\s+myGlobal/.test(code), ''<code>myGlobal</code> should be declared using the <code>var</code> keyword'');'
- text: <code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, ''<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>'');'