This forum is now read-only. Please use our new forums! Go to forums
"R, P, S" 5/9
Code is as follows:
var userChoice = prompt(“Do you choose rock, paper or scissors?”);
var computerChoice = Math.random();
if (computerChoice < 1/3) {
computerChoice = “rock”;
} else if(computerChoice <= 2/3) {
computerChoice = “paper”;
} else {
computerChoice = “scissors”;
}
console.log(“User: “ + userChoice);
console.log(“Computer: “ + computerChoice);
var compare = function(choice1, choice2){ if(choice1 === choice2) { return “The result is a tie!”; } }; compare()
As such this is being accepted, but when i run through it, it seems that every possible result is giving the “The result is a tie!” output. Basically I can’t figure out what is being compared with “var compare = function(choice1, choice2)”
Any help would be appreciated!
BR /Tonny
Answer 55ddfedad3292f25a70001db
Have read through http://www.codecademy.com/forum_questions/559dcb4be39efe550f00006b
Reference
google search == the Book == javascript [your question] site:developer.mozilla.org
== discussions / opinions == javascript [your question] site:stackoverflow.com
== guidance == www.crockford.com http://javascript.crockford.com/code.html http://javascript.crockford.com/survey.html https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency