Error:access is denied,why is it?


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


#2

@ajaxblaster57790,
-1
comment-out the call of the compare-function
// compare(userChoice, computerChoice)
as it might be it frustrates the code-checker.

-2
Do not use a semi-colon-; on the IF ELSE-IF statement structure
== http://stackoverflow.com/questions/17036135/why-is-it-that-semicolons-are-not-used-after-if-else-statements ==

-3
every return-statement line should end with a semi-colon-;
as it is the End-of-Statement indicator

-4
every var statement should end with a semi-colon-;
var compare = function(choice1.choice2) { };

-5
Your access problem could have been temporary
as the codecademy.com site will have been bombarded with logon-requests
after the October-Newsletter was distributed....
I Iost connection, working from the Netherlands.

-6
Concerning the execution of your compare =function=
please read
http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b


#3

Thanks you so much!it works already!Thanks!!


#4

@ajaxblaster57790,
but you did look at =6b link
as you are using the return-statement, you will get a result with NO-Display....

console.log( compare(userChoice,computerChoice) );


#5

but it displays the result, for example I copied pasted this:
Computer: paper
paper wins
,may I know why is it so, even without the console.log?


#6

The Display is the result of the checks by the code-checker software.
At the END of your code add a code-line
console.log("== This my END ==");
every output coming after that will be the code-checker.