Lesson 6 & 7 problems


#1



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


I have linked lesson 7 of the rock-paper-scissors conundrum I have encountered, but this begins with the previous lesson.
Before, I was convinced lesson 6 was "glitched" to one extent or another, as it informed me of an unexpected token else. In a forum, a user had posted their solution, which included eliminating the "else if" and creating a complex string of "if's" as you can see in the code I posted.
I am not running into the very same error with lesson 7. I have inputted the correct code. I am taking these lessons alongside two other people and they have confirmed that they have done exactly as I have done. And yet I still run into this issue.
I assume that it may have to do with the seemingly erroneous code (the long "if" i had posted, pertinent to the sixth lesson), but I also think something is wrong. I was told it was correct, and now, once again following the exact code as my partners, I am still incorect?? Thank you in advance.


var compare = function(choice1, choice2) {
    if (choice1 === choice2) {
        return "The result is a tie!";
    }
    if (choice1 == "rock") {
        if (choice2 == "scissors") {
            return "rock wins";
        } else {
            return "paper wins";
        }
    }
    if (choice1 == "paper") {
        if (choice2 == "scissors") {
            return "scissors wins";
        } else {
            return "rock wins";
        }
    }
    if (choice1 == "scissors") {
        if (choice2 == "rock") {
            return "scissors wins";
        } else {
            return "rock wins";
        }
    }
}


#2

At first see it

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

is it right????

and second

at last you have to call the function

compare(arg1,arg2);

@paperhen


#3

This makes sense. Thank you so much, @rcodeman


#4

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";
}
else if (choice1==="paper")
{
    if (choice2==="rock")
    return "paper wins";
}
else
{
    return "scissors wins";
}

};
..............guys am stuck o this code its not working can you help????