Skip to content

Instantly share code, notes, and snippets.

@elledienne
Created June 26, 2017 21:00
Show Gist options
  • Save elledienne/bc33821eec183dfc119b43673a24337d to your computer and use it in GitHub Desktop.
Save elledienne/bc33821eec183dfc119b43673a24337d to your computer and use it in GitHub Desktop.
[INTERVIEW] Coding challenge to test hoisting knowledge
// 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); // ???
}
@elledienne
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment