FUNCTIONAL SCOPE w0t?


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-javascript/lessons/scope/exercises/functional-scope?action=lesson_resume&link_content_target=interstitial_undefined

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I am having trouble figuring out on how to declare the function myApartment. So far throughout the lesson, when we declare a function it usually comes in this structure. EX: function myFunction(parameter) {
}
but for this lesson in particular, why do we declare a variable and name it myApartment and then assign its value with a function?
Ex: var myApartment = function(parameter) {
}

and when I look at the hints it gives me this as an example:

function myApartment() {
}
instead of the one prior to that one.

ORRRRR… Is it because it is specific to functional scope which means you have to assign a function to a variable?
AM I MAKING ANY SENSE

I eventually let it run the code for me, and it set it to the code where the function is assigned to the variable. halp me pls!?

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

function myApartment() {
  var mailBoxNumber = 'Box 3';
  var laundryRoom = 'In-Unit';

  console.log('Mail box: ' + mailBoxNumber + ', Laundry:' + laundryRoom);

}

myApartment();

Replace this line with your code. 



#2

there are two ways to define a function, see the documentation:

there is function deceleration and function expression.

Both can used, each has its pro’s and cons. For this exercise, it shouldn’t matter, its about the scope of mailBoxNumber and laundryRoom


#3

Okay, thanks. I was wondering why they did that! But now I know there are two ways of doing it. Thank you for explaining. I really appreciate it!


#4