Given the following code:

var b = 6;

var foo = function (a) {
    a = b + a;
    return function () { return a; };
};

b = 2;

var bar = function () {
    var b = 3;
    return foo(b);
};

what does bar() evaluate to?

a function
  • 9
  • 5
  • 6
  • error

Determine what the foo and bar functions return.

Keep in mind the difference between a function definition expression and a function call.

Note that the code defines two variables called b.