Functional Scope


Well, according to the instructions, i am asked to write a function named myApartment before the console.logs from the last exercise. But, shouldn't the function look like this "function myApartment() " ?

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);



That is short-hand for same thing.
general way..
var x = function(parameters){

function x(parameters) {

also check this, a good discussion on it.. (a very good discussion)



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