Reason for the order of else if / if else statements


#1


https://www.codecademy.com/courses/javascript-beginner-en-Bthev-mskY8/1/4?curriculum_id=506324b3a7dffd00020bf661

What is the precise reasoning behind using the unusual order of these if / else if / if else statements? At the beginning of the lesson, if else and else if statements seemed standard. Now the order and use seem arbitrary. I just would like to know how this is the best order.
Thank you.


var compare = function(userChoice, computerChoice) {
if (userChoice === computerChoice) {
    return "The result is a tie";
}
else if (userChoice === "rock") {

    if (computerChoice === "scissors")
        return "rock wins";
    }   
    else {
        return "paper wins";
    }
}


#2

@logosghost,
To get an idear
Please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
and concentrate on:

  • the creation of the compare function
  • the truth-table
  • the build of the IF ELSE-IF statement structure as part of the compare FUNCTION-BODY
  • the execution of the compare function (keeping in mind that the return statement is used )