BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup

Join the forum, it's quick and easy

BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup
BullyWiiHacks
Would you like to react to this message? Create an account in a few clicks or log in to continue.
BullyWiiHacks

Gaming, Modding & Programming

Important reminders:

- Click *HERE* for advanced forum search or check out the text field below on the front page for Google before posting
- NO support via private message (use the forum)
- Write meaningful topic titles
Site Translation
Latest topics
» Lego Stars Wars: The Complete Saga [RLGE64]
[Help]JavaScript Unexpected end of input Empty11/12/2024, 3:19 am by SnB@BWH

» JMaster Duel Bot: A Yu-Gi-Oh! Master Duel Bot and Trainer for Steam
[Help]JavaScript Unexpected end of input Empty11/10/2024, 5:26 am by Bully@WiiPlaza

» Error Injecting Drool Links Saliva Mod Menu
[Help]JavaScript Unexpected end of input Empty11/10/2024, 5:24 am by Bully@WiiPlaza

» USB Gecko problems with some games
[Help]JavaScript Unexpected end of input Empty10/16/2024, 1:59 pm by Reclaimer Shawn

» Metal Gear Solid V The Phantom Pain X Flashpoint Batman Gameplay unedited [Seth@WiiPlaza]
[Help]JavaScript Unexpected end of input Empty9/23/2024, 12:48 pm by Seth@WiiPlaza

» Dropped Out of College to Pursue Web Dev and Life Pursuits in General
[Help]JavaScript Unexpected end of input Empty8/9/2024, 7:09 am by SnB@BWH

» ASM <> Gecko Code Converter
[Help]JavaScript Unexpected end of input Empty7/29/2024, 11:15 am by Mac11ngAround

» German With a Jackhammer
[Help]JavaScript Unexpected end of input Empty7/28/2024, 3:42 pm by SnB@BWH

» Wii RAM Hacking: Pointers and ASM
[Help]JavaScript Unexpected end of input Empty7/23/2024, 1:54 pm by Mac11ngAround

» IBM AIX Assembler Programming Reference - Useful For PPC ASM
[Help]JavaScript Unexpected end of input Empty7/21/2024, 5:00 pm by Mac11ngAround

Search
 
 

Display results as :
 


Rechercher Advanced Search

November 2024
MonTueWedThuFriSatSun
    123
45678910
11121314151617
18192021222324
252627282930 

Calendar Calendar

Country Statistics
Free counters!

You are not connected. Please login or register

[Help]JavaScript Unexpected end of input

3 posters

Go down  Message [Page 1 of 1]

Shadow@BWH

avatar
 
 

Okay so I'm just trying to make a rock paper sicors game and I keep getting a error no matter what I do it won't take my code. I went as far as coping the code they gave me in the hint and it still says it's wrong. Here's the code.

Code:
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 (choice2 === "scissors") {
        return "rock wins";
    } else {
        return "paper wins";
    }

}


_________________
[Help]JavaScript Unexpected end of input BAjMdNS

SnB@BWH

SnB@BWH
Admin & Writer

I don't know JavaScript, but the error means you forgot to close the statement(s). Take a closer look at your semi-colons and brackets.


_________________
[Help]JavaScript Unexpected end of input Simple10

[Help]JavaScript Unexpected end of input LSTjSyDDiscord: SnB_BWH

Click HERE to earn free bitcoin, litecoin, dogecoin, and dash!

Win Free Bitcoins every hour!

Bully@WiiPlaza

Bully@WiiPlaza
 
 

If you format your code properly you might be able to tell where the mistake lies.

I did it for you:
http://pastebin.com/qLApgJ8g

Now it's clear to me what went wrong, also to you? Wink


_________________
[Help]JavaScript Unexpected end of input YBjg74I

Shadow@BWH

avatar
 
 

I did it exactly like that I copied it into it and it still gives me the same error. I'm wondering if it's a bug in the program. I clear up one issue and it just gives me another. It starts you off with this.

Code:
var compare = function(choice1, choice2) {
    if(choice1 === choice2) {
        return "The result is a tie!";
    }
};

So adding to it it would be this

Code:
 } else if (choice1 === "rock")
    {
        if (choice2 === "scissors")
        {
            return "rock wins";
        } else
        {
            return "paper wins";
        }
    }

But it won't take the }; at the end of the first part and it gives you this.

SyntaxError: Unexpected token }

So I get rid of the extra part that is giving the error.

https://i.imgur.com/Ae2e2rX.png

and then it gives me this error

SyntaxError: Unexpected token else

The code is exactly how the person who gave it is.

Code:
if(choice1 === choice2) {
    return "The result is a tie";
}

else if(choice1 === "rock") {

    if(choice2 === "scissors") {
        return "rock wins";
    }
    else {
        return "paper wins";
    }

}

I'm absolutely astounded and baffled by it.



Last edited by Shadow@BWH on 12/6/2014, 1:05 pm; edited 1 time in total


_________________
[Help]JavaScript Unexpected end of input BAjMdNS

Bully@WiiPlaza

Bully@WiiPlaza
 
 

I didn't fix the code, I just formatted it for you to see better what's wrong.


_________________
[Help]JavaScript Unexpected end of input YBjg74I

Shadow@BWH

avatar
 
 

I added to my last comment. Wait..... I left a bracket open didn't I....

and just like that I fixed it. Thanks Bully Razz I feel really dumb when I do stuff like this.

Code:
 var compare = function (choice1, choice2) {
     if (choice1 === choice2) {
         return "The result is a tie!";
     }
 };
 if (choice1 = "rock") {
     if (choice2 = "scissors") {
         console.log("rock wins");
     } else {
         console.log("paper wins");
     }
 }


_________________
[Help]JavaScript Unexpected end of input BAjMdNS

Bully@WiiPlaza

Bully@WiiPlaza
 
 

Exactly, a closing bracket was missing. Very Happy


_________________
[Help]JavaScript Unexpected end of input YBjg74I

SnB@BWH

SnB@BWH
Admin & Writer

I hate using languages that uses brackets or semi-colons because 90% of the time the error(s) you get are because of a semi-colon or bracket. The IDE should automatically correct it for you, but then what do you learn? lol


_________________
[Help]JavaScript Unexpected end of input Simple10

[Help]JavaScript Unexpected end of input LSTjSyDDiscord: SnB_BWH

Click HERE to earn free bitcoin, litecoin, dogecoin, and dash!

Win Free Bitcoins every hour!

Bully@WiiPlaza

Bully@WiiPlaza
 
 

shitnbitch@BWH wrote:I hate using languages that uses brackets or semi-colons because 90% of the time the error(s) you get are because of a semi-colon or bracket. The IDE should automatically correct it for you, but then what do you learn?  lol
It doesn't know how to correct syntax errors but it can show you where (approximately) an error lies because when it compiles it gets stuck somewhere close to the error. Eclipse does a good job in highlighting the spot:
[Help]JavaScript Unexpected end of input Eclips10

Mostly it's really easy to fix mistakes then:
[Help]JavaScript Unexpected end of input Eclips11


_________________
[Help]JavaScript Unexpected end of input YBjg74I

Shadow@BWH

avatar
 
 

Ya I normally use jsfiddle to test the codes to make sure there working. Sometimes I just go full idiot and can't see what's in front of me.


_________________
[Help]JavaScript Unexpected end of input BAjMdNS

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum