Please help


#1


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


Oops, try again. Your code returned 'Scissor wins' instead of 'undefined' when the inputs are scissors and rock


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


#2

You misspelled one variable (inside if statement).
Review your error and check for it.


#3

Hello, I need help also, I am absolute beginner on JS and I am trying to read this code on below. The part i did not understand is the last 2 line. A smiley face is turning around with a blue stick. But in which part of the code I am saying that the blue stick should be attached to smiley face?

When I write last line smiley, before color (blue), blue stick starts from the middle of the face. In JS how do code lines make different, should there be an order?

// The old smiley function from the previous step
function smiley(x, y) {
  moveTo(x, y);
  color("yellow");
  circle(0, 0, 50);
  color("black");
  circle(-20, 10, 7);
  circle(20, 10, 7);
  lineWidth(3);
  path("g -20 -10 q 20 -10 0 -50 c");
  goBack();
}

function drawing() {
  // The angle variable stores the current rotation
  var angle = 0;
  // Draw twenty frames per second (20 * 50 = 1000 milliseconds)
  setInterval(frame, 10);
  function frame() {
    // Clear the screen
    clear();
    // Update the angle
    angle = angle - 2;
    // Rotate what we are about to draw
    rotate(angle);
    // A stick...
    color("blue");
    box(-5, 100, 10, 150);
    // with a smiley on top
    smiley(0, 100);
  }
}

#4

you should put some if/else statement.


Virus-free.
www.avg.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


#5

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