Results 1 to 2 of 2
  1. #1
    megarobot524 is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Question Need Code Feedback | And Why Do I Get This Error?

    Hey guys heres my code!:
    THE BOLD AND BLUE IS TO SHOW YOU WHAT MY CODE AND ERRORS ARE.

    confirm("Are you ready to know you're age in dog years? :D");
    var age = prompt("How old are you?");
    var age = function (number) {
    var val = number * 4 - 2 + 21;
    console.log(val);
    }


    Please tell me if I have any syntax errors or ways to improve it! Additionally can someone please tell me what this means and how do I fix it? So I'm trying to compile it and I get all this:

    Human2DogConversion.java:1: class, interface, or enum expected
    confirm("Are you ready to know you're age in dog years? :D");
    ^
    Human2DogConversion.java:2: class, interface, or enum expected
    var age = prompt("How old are you?");
    ^
    Human2DogConversion.java:3: class, interface, or enum expected
    var age = function (number) {
    ^
    Human2DogConversion.java:5: class, interface, or enum expected
    console.log(val);
    ^
    Human2DogConversion.java:6: class, interface, or enum expected
    }
    ^
    5 errors


    Please help! THANKS!!!

  2. #2
    AndrewM16921 is offline Senior Member
    Join Date
    Jan 2009
    Location
    CA, USA
    Posts
    264
    Rep Power
    6

    Default Re: Need Code Feedback | And Why Do I Get This Error?

    First, this is a Java forum - NOT a JavaScript forum. They are very different languages. Though I am confused... that looks like JS but you're getting Java errors? I hope you're not trying to compile JS with a Java compiler. JS is not a compiled language.

    Second, when/if you do post Java code, please use the [code][/code] tags.

    EDIT:

    I ran your code through javac. It seems you are indeed trying to compile JavaScript with a Java compiler. These are two completely different languages. Are you trying to learn Java or JavaScript?

    For Java: http://docs.oracle.com/javase/tutorial/java/

    For JavaScript: http://www.w3schools.com/js/default.asp
    Last edited by AndrewM16921; 09-19-2013 at 06:49 AM.

Similar Threads

  1. Need feedback with my code, thank you
    By Dai in forum New To Java
    Replies: 10
    Last Post: 09-19-2013, 08:43 AM
  2. UML feedback
    By behedwin in forum New To Java
    Replies: 0
    Last Post: 10-05-2012, 11:21 AM
  3. Feedback
    By GrumpyBum in forum Suggestions & Feedback
    Replies: 0
    Last Post: 04-25-2012, 11:34 AM
  4. Feedback on my PrimeNumber Finder code please.
    By fatabass in forum New To Java
    Replies: 4
    Last Post: 12-22-2011, 10:43 PM
  5. Calculator Feedback
    By 0026sd in forum New To Java
    Replies: 0
    Last Post: 09-20-2011, 02:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •