Created
June 26, 2017 21:00
-
-
Save elledienne/bc33821eec183dfc119b43673a24337d to your computer and use it in GitHub Desktop.
[INTERVIEW] Coding challenge to test hoisting knowledge
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
// Remember to overwite the code in CodeShare, JSFiddle, etc. to restore the inital state of the test and to avoid | |
// showing to candidates the changes made during other interwies | |
// TASKS: | |
// 1. Ask to developer to go through the file and analyze it. The dev should: | |
// - Notice that the first comment return "undefined" | |
// - Notice that the second comment return "of Barcelona's weather" | |
// - Talk about hoisting | |
// - Identify what would happen if we would use "let" instead of "var" (ReferenceError: testVar is not defined) | |
var testVar = "I'm very jealous"; | |
function tryMe() { | |
console.log(testVar); // ??? | |
var testVar = "of Barcelona's weather"; | |
console.log(testVar); // ??? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Links
CodeShare - JSFiddle