Improvement to "I have to celebrate you baby"


#1

The lesson indicates we should use a "switch" statement. I think this is very inefficient. We could instead do this and save a lot of typing:

var getReview = function (movie) {

    for (var movieName in movieCollection) {
        if (movieCollection[movieName].name === movie) {
            return movieCollection[movieName].review;
        }
    }
    return console.log("I don't know!")
};

#2

@systemslayer17867,
But they want to introduce the switch statement

In
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch
[quote]

switch (parameter-expression) {
  case value1:
    //Statements executed 
    //      when the VALUE of expression matches value1
    [break;]
  case value2:
     //Statements executed 
    //      when the VALUE of expression matches value2
    [break;]
 ...
  case valueN:
    //Statements executed 
    //      when the VALUE of expression matches valueN
    [break;]
  default:
    //Statements executed 
    //      when none of the VALUE's match the VALUE of the expression
    [break;]
}

= = = = = = = = = = = = = = = = = = = = = = = = = = = =

The switch statement evaluates an parameter-expression,
matching the parameter-expression's VALUE to a case clause,
and executes statements associated with that case.
( and with the break or return-statement will exit the switch statement )
[end-quote]


#3

All they say in the lesson is something like "use a concept from a previous lesson." In previous lessons, we covered both switch statements and the "for - in" syntax. The latter is more efficient in this case.

So, I think the lesson should be revised from instructions saying "use a concept from a previous lesson" to "use a switch statement."