Help on 4


#1

var userChoice = prompt("Do you want to choose rock, paper or scissors?")
var computerChoice = Math.random()
{console.log(computerChoice)};
{
if(computerChoice<=0.33){
"rock"}
if else(computerChoice<=0.66){
"paper"}
else(computerChoice)<=1{
"scissors"};
}

Where am I going wrong?


#2

you want to updated computerChoice with rock, paper or scissors so you can compare choices later, for example to update to rock in your if clause:

computerChoice = "rock"

a single equal sign will assign a new value to a variable. same for paper and scissors

Oh, and one more thing. else means everything else, it can't have a condition


#3

so.... write the the new value for the variable within the curly brackets, yeah?


#4

i assumed that much was obvious


#6

var userChoice = prompt("Do you want to choose rock, paper or scissors?")
var computerChoice = Math.random()
{console.log(computerChoice)}
(
if(computerChoice<=0.33){
computerChoice = "rock"}
if else(computerChoice<=0.66){
computerChoice = "paper"}
else(computerChoice<=1){
computerChoice = "scissors"};
)

still a problem with my syntax


#7

my answer can contain multiply corrections.


#9

Hi Matthewfallon33,
In the if..else condition statement you have wrongly coded "if else". It should be "else if".


#10

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