What's wrong with my javascript code?

It's on droid script...

Attachment image

3 Answers

  • 4 weeks ago
  • Chris
    Lv 7
    1 month ago

    I guess you should take another look at the tutorial: http://androidscript.org/droidscript/tutorials/?tu...

    Programming doesn't mean you just make a bad guess at how the program could look like, then immediately ask online for help; you need to actually learn how the language works and what the syntax is.

  • 1 month ago

    I waited for someone with more JS experience to answer.  Didn't happen.

    The image is fuzzy, but it looks like there's something (a thin space or maybe a '.') between "on" and "start".  That's not a valid object name in JS.  A name can only contain letters, digits, dollar ('$') signs and/or underscores ('_') and can't begin with a digit.  No spaces or other characters are allowed.  Those are the rules for ASCII characters.  Unicode allows some extra options, like letters from non-English alphabets, but I haven't had the need for any of that. 

    The "var" declaration inside the function is missing the variable.  A declaration gives a variable a name, and optionally a value.  It looks like:

        var grunt = "lemme smash";

    After that, a variable named "grunt" is defined and refers to the string value "lemme smash".

    You aren't using any variables in your function, though, so I don't know why you even have a var statement.  If it's because you're going to use the string "lemme smash", don't bother.  String literals don't need to be declared.

Still have questions? Get your answers by asking now.