Whats wrong with my code ? :/


#1

/*var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
	computerChoice = "rock";
} else if(computerChoice <= 0.67) {
	computerChoice = "paper";
} else {
	computerChoice = "scissors";
} console.log("Computer: " + computerChoice);*/
var compare = function ( choice1 , choice2 ){
    if (choice1 === choice2 ) {
        return "The result is a tie!";
    }
    else if(choice1==="rock")
    {
        if ( coice2==="scissors")
        {
            return "rock wins";
        }
            else
            {
                return "paper wins";
            }
    }
    else if (choice1 ==="paper")
    {
        if(choice2 === " rock")
        {
            return "paper wins" ;
        }
        else {
            return "scissors wins";
        }
    }
        
}

#2

@arraysolver36165,

Have a close look at

coice2

and
read code-convention
http://javascript.crockford.com/code.html

and
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 )

and
maybe next time you could mention which Oops- or Error-message you are witnessing...

and
re-edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697
[extra's]
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet


#3

hy , sir i've studied the truth and trace table in the m131 discrete math and m129 numerical .
and m150a javascript part 1 in university so i know that t&f =f
f&f=f
t&t=t
t||f=t
t||t=t
f||f=f
and of course ther is the negation , the exclusive or .
but what the combination between the if statement and the truth table ?


#4

Actually it is && not & (& is only meant to be used for binary AND).