ShagFace
|
  |
| Joined: 22 Aug 2011 |
| Total Posts: 3474 |
|
|
| 28 Sep 2014 06:24 PM |
Alright, so I created a script for a RPS game, however the script keeps telling me there's a "Syntax Error: Unexpected token else"
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!"; } compare(else if (choice1 === "rock") if (choice2 == "scissors") return "Paper wins"; } };
If anyone could help me, I'd seriously appreciate it Thanks |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 06:25 PM |
| you should go to scripters, most people here specialize in RBX lua not java or w/e this is |
|
|
| Report Abuse |
|
|
ShagFace
|
  |
| Joined: 22 Aug 2011 |
| Total Posts: 3474 |
|
| |
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 28 Sep 2014 06:27 PM |
| What has Lua done to deserve this pain. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 28 Sep 2014 06:29 PM |
^ lol this is javascript
@op
try: } else if (computerChoice > 0.67) {
instead of } else { |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 28 Sep 2014 06:41 PM |
| Ignore that post there ^^^^ op, listen to my post on your thread in scripters. |
|
|
| Report Abuse |
|
|