Not being able to pass 2. Functional Scope


#1

https://www.codecademy.com/courses/learn-javascript/lessons/scope/exercises/functional-scope?action=lesson_resume&link_content_target=interstitial_lesson

The exact question that I'm stuck is #4, "Now, let's try to see the mailBoxNumber outside the function. On the last line of the program, write: [console log code here]"

When I submit the answer below, it still doesn't pass me. What am I doing wrong?

The error message that I am getting is:
"Did you write a console.log with the variable mailBoxNumber in it after the myApartment function?"


var laundryRoom = 'Basement';
var mailRoom = 'Room 1A';

var myApartment = function() {
  var mailBoxNumber = 'Box 3';
  var laundryRoom = 'In-unit';
  console.log('Mail box: ' + mailBoxNumber + ', Laundry:' + laundryRoom);
};

myApartment();
console.log(mailBoxNumber);


#2

Hi,
Yes,I am having the same problem. My code looks identical to yours.


I can't figure out the part on functional scope 2/4 instruction number 4
#3

I was having the same problem... I put the
console.log(mailBoxNumber);
before:
myApartment();

like this:

var laundryRoom = 'Basement';
var mailRoom = 'Room 1A';

var myApartment = function() {
var mailBoxNumber = 'Box 3';
var laundryRoom = 'In-unit';
console.log('Mail box: ' + mailBoxNumber + ', Laundry:' + laundryRoom);

};

console.log(mailBoxNumber);
myApartment();

and it finally worked for me :slight_smile:


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.