Step 6: I am having problem with my code, please assist. Thankyou


#1

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/javascript-beginner-en-Bthev-mskY8/1/2?curriculum_id=506324b3a7dffd00020bf661#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>

Oops, try again.
There was a problem with your syntax.
```

Replace this line with your code.

compare = function(choice1, choice2) {
if(choice1 === choice2) {
return “The result is a tie”;
}

else if(choice1 === “rock”) {

if(choice2 === "scissors") {
    return "rock wins";
}
<do not remove the three backticks above>

#2

HI it’ s missing the else stateemnt and it should have that structture (the else if statement)

else if (condition) {
    if (condition) {
        #do something
    }
    else {
        #do something
    }
}

#3

Thanks but am not getting it. What part should I edit or where…? Thanks

if(choice1 === choice2) {
return “The result is a tie”;
}

else if(choice1 === “rock”) {

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

}


#5

Now you should close the compare function

var compare = function(choice1, choice2) {
   /*Here put the esle if statement*/
};

#7

Should the ; symbols be there? Its still not working…


#8

Yes you can put it ;… can you post your new code if you didn’t pass the lesson.


#9

Thanks Wizmarco. But am still stuck, for almost an hour now. This is my new code from what am understanding… Kindly have a look at it and tell me what is wrong. Thankyou.

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return “The result is a tie”;
else if(choice1 === “rock”)
};

{

if(choice2 === "scissors") {

    return "rock wins";
}
else {
    return "paper wins";
}

}


#10

Here

var compare = function(choice1, choice2) {
    if(choice1 === choice2) {
        return "The result is a tie";
   }  <-- #you hould close the if statement here

    else if(choice1 === "rock")
   }; <-- #rmeove this };
   {
        if(choice2 === "scissors") {
            return "rock wins";
        }
        else {
            return "paper wins";
        }
   }
} # add thsi one for closing the compare function

REAd the comments


#11

Thanks so much Wizmarco. It has worked at last after fixing the above issues. Help appreciated. Have a good day…

This is my code which has worked.

var compare = function(choice1, choice2) {
if(choice1 === choice2) {
return “The result is a tie”;
}
else if(choice1 === “rock”)

{

if(choice2 === "scissors") {

    return "rock wins";
}
else {
    return "paper wins";
}

}
}


#12

YOur welcome… you can read thsi post it’s about how to format the code


#13

Again thank you very much.


#14

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