Question: Scope The following code snippet contains two console.log() statements. Choose the correct output corresponding to each statement, considering that each statement is executed individually. var

Scope

The following code snippet contains two console.log() statements. Choose the correct output corresponding to each statement, considering that each statement is executed individually.

var x = 22;

var a = 5, b;

function foo() {

var y = 7;

b = 2;

}

console.log(x / y);

console.log(a / b);

A. 3.142857142857143

2.5

B. 3.14 undefined

C. Uncaught ReferenceError: y is not defined

2.5

D. Uncaught ReferenceError: y is not defined

NaN

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!