Quiz: Hoisting
This lesson will test your understanding of hoisting in JavaScript.
We'll cover the following
Question 1 #
Q
Study the code below:
function Add(){
console.log(answer)
var answer = 2
};
Add()
What will be the output of the following code?
A)
2
B)
4
C)
undefined
D)
Error
Question 2 #
Q
Study the code below:
var temp= 'hi';
function display(){
console.log(temp);
var temp = 'bye';
};
display();
What will be the output of the code?
A)
hi
B)
bye
C)
undefined
D)
Error
Let’s discuss the answers in the next lesson.