Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Web languages(HTML, CSS, JS, jQuery, etc.)] What is wrong with this????
#1
Please help!
Code:
var userChoice = prompt("Do you choose rock,paper or scissors?");
var computerChoice = Math.random();
if (computerChoice <= 0.33); {
console.log("Rock");
}
else if (computerChoice >= 0.34, computerChoice <= 0.66)
{
    console.log("Paper");
    
}
else {
    console.log("Scissors");
}
[Image: Untitled_1.jpg]
Reply
#2
Im not a coder, but do you miss ; on
}
else if (computerChoice >= 0.34, computerChoice <= 0.66) <-- ;
{
[Image: uHVrTMF.jpg]
Reply
#3
(04-06-2014, 09:18 AM)Tumppi⁴²⁰ Wrote: Im not a coder, but do you miss ; on
}
else if (computerChoice >= 0.34, computerChoice <= 0.66) <-- ;
{



Generally, the syntax is going to be:

if (booleanEvaluation)
{
// do something
}

It looks like you added an extra semicolon in an IF statement:

Code:
if (computerChoice <= 0.33); {
Should be:
Code:
if (computerChoice <= 0.33) {
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)