Solution Review: Hoisting

In this lesson, we will discuss the solutions to the questions in the previous lesson.

Question 1: Solution review #

Explanation #

Run the code from the question below:

Press + to interact
function Add(){
console.log(answer)
var answer = 2
};
Add()

The above code displays undefined as an answer due to the concept of hoisting in Javascript.

Hoisting

...