JavaScript HELP!!!!!!! (if/else if/else)

Discussion in 'Technology Talk & Help' started by LegitimateCheese, Nov 1, 2013.

Thread Status:
Not open for further replies.
  1. Can someone please tell me what I did wrong. And by the way here is what that red x says for line 10:
    Expected an identifier and instead saw 'else'.
    Missing ";" before statement

    If you can't see the picture well enough its made to have a resolution of 1600x900 so if you just do ctrl+ you should be able to see it just fine.
    [​IMG]
     
    Last edited: Nov 1, 2013
    Posted Nov 1, 2013
    #1
  2. Maddog

    Maddog

    547
    72
    8
    [MENTION=4424]Slushee[/MENTION]

    else if (computerChoice <= 0.66); {

    }

    Remove the ;




    Code:
    var userChoice = prompt("Do you choose rock, paper, or scissors?");
    var computerChoice = Math.random();
    console.log(computerChoice);
    if (computerChoice <= 0.33) {
        computerChoice = "rock";
    }
    else if (computerChoice <= 0.66) {
        computerChoice = "paper";
    }
    else {
        computerChoice = "scissors";
    }
    
     
    Last edited: Nov 1, 2013
    Posted Nov 1, 2013
    #2
  3. Yep. Don't use ; when dealing with if statements, for loops, etc.
     
    Posted Nov 1, 2013
    #3
  4. SinS

    SinS

    39
    0
    0
    If only I could code some stuff...
     
    Posted Nov 1, 2013
    #4
  5. Well SinS if you're interested go to codecademy.com
    I learned HTML and CSS with that site and it's one of the easiest things I've ever done. The way they design the lessons makes it so understandable. Now that's just for web development. If you looking to learn something like javascript they teach that plus several other scripting languages. Now if you were looking to learn something more related to gaming like Java or some version of the C language then you would have to find a different site for that. Unfortunately they don't teach anything that strongly relates to gaming. When people see code it usually looks very overwhelming like something only a genius could do, but if you are dedicated to it you'll probably find that it's not as difficult as you thought. Then again, you might try hard to learn and then just hate it. I really enjoy it thought because this is what I plan on doing as an adult. I would prefer to go into game programming but if not then I would probably try cyber security and I could always to web development on the side. Okay now I'm just rambling about stuff. Lettin them thoughts flow, man...
     
    Posted Nov 1, 2013
    #5
  6. Oh and thanks for the help guys I'll try that :D
     
    Posted Nov 2, 2013
    #6
  7. When I first started learning how to code I wanted to be a game developer, I think everyone did. Yeah not anymore, haha; being a game dev would suck.
     
    Posted Nov 2, 2013
    #7
  8. Swagijuana

    Swagijuana Member

    931
    600
    9
    That's why people use things such as the Unreal Development Kit. Game developing software without the coding, but still getting to use design, modeling, and other fun things that go into game development. Bioshock and Unreal Tournament? Completely made with UDK.

    Also, I hope you guys are just using JavaScript as a starting language, not for game development. It's great for learning languages that use C-style syntax, i.e. C++, which C++ is awesome for game development, especially for Xbox game development(XNA). If you're going to eventually learn Lua, I wouldn't go to much farther with JavaScript.


    If interested in game devlopment or coding for 3D cameras and sensors, go ahead and look below!

    I have something awesome that researched a few years ago when first starting out with a language other than JavaScript. It got me starting to code in Visual Studio (it's what I use. Yes, pirated. Download a free IDE if you wish, like Eclipse). The Kinect Development Kit. All you need is your Kinect if you have an Xbox (Kinect for Windows has more capability than the Xbox model. At least true for the 360 Kinect model). Your Kinect should've came with a USB adapter. Go ahead and install your IDE, Kinect SDK, and then plug in your Kinect. You're ready to code Kinect technology and games. Basic C++ and knowledge of your IDE will be sufficient for learning. This project teaches basics of game development, C++, body recognition in cameras, and XNA.

    But, the Kinect SDK is limited to only the Kinect. If you're interested in coding for other infrared/RGB colored cameras like the Kinect, research OpenNI. Awesome for coding middleware to communicate with 3D cameras and sensors. You can use your Kinect for this if you get the Kinect mod for OpenNI. OpenNI can communicate in C++, but there's other SDKs that can be used with OpenNI (I forget what, but there was an awesome middleware library that used C++, C#, and/or JavaScript with OpenNI).

    Edit: Found that "awesome middleware library". It's called OpenCV. Can code with in C++, C#, Java, and Python.
     
    Last edited: Nov 2, 2013
    Posted Nov 2, 2013
    #8
  9. The thing about most programming languages is that they are usually very similar. I think Java is probably a good starter, because when you learn something such as python or lua, you'll be so amazed at how simpler it is than java :p
     
    Posted Nov 2, 2013
    #9
  10. Swagijuana

    Swagijuana Member

    931
    600
    9
    Java is awesome. It's capabilities are beyond most languages, unlike Javascript, which is pretty limited. I spent a few dozen hours going through the Java tutorials. It's a must read for anyone wanting to code. It explains things such as being an Object-Oriented Programming language, which is my favorite view on coding anything.
     
    Posted Nov 2, 2013
    #10
Thread Status:
Not open for further replies.