Last active
July 24, 2016 21:18
-
-
Save farmanp/c8cb7be1b3ce2c0d8a682c526ac2544e to your computer and use it in GitHub Desktop.
Create a variable outside the global scope
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a function that holds another function which will "create" a name | |
function init(){ | |
// Global variable inside the function to be used after initialization | |
firstName = "FIRST NAME" | |
// Second function is what returns the global variable | |
function createName(n){ | |
return n | |
} | |
return createName(firstName); | |
} | |
// Run the function | |
init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment