Functional Scope


#1


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


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

myApartment();


#2

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

shorthand
function x(parameters) {

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

LINK


#3

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