Part 5 compare


#1


function compare = (Choice1, Choice2)
{
    if (Choice1 === Choice2)
    {
    return "The result is a tie";
    }


#2

i forgot to mention i am using Linux mint


#3

var compare = function(choice1,choice2)
{
if(choice1 === choice2)

return "The result is a tie!";

};


#4

Check your braces. there is one missing.


#5

Solved it one 2 many brackets


#6

thanks but I guess in Linux it only requires 2


#7

Solved why is it the simple things that always get me?


#8

I wouldn't take that for granted. Your if statement has only one line. It would be different if more than one. Best practice is to use block syntax religiously while studying this track. Learning good syntax practice first, before cataloging the shortcuts will pay off in the short and long haul.


#9

So true I learned that It is all about indentation.


#10

Indentation in JS is all about readability and being able to spot nesting, but it is not a requirement insofar as syntax is concerned. I call it 'blocking' and like to encourage new learners to use the preparation approach to writing their code.

    if () {
        // statement
    }
    else if () {
        if () {
            // statement
        } else {
            // statement
        }
    } else {
        // statement
    }

We can see all the necessary brackets and are ready to fill in the conditional expressions and statements.


#11

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