Coding Help

Discussion in 'Off-Topic' started by Dccciz, Sep 2, 2013.

  1. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
    [​IMG]

    Any help would be appreciated! :p
     
  2. RyanJF1

    RyanJF1 Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Jul 1, 2012
    Messages:
    6,464
    Trophy Points:
    47,990
    Gender:
    Male
    Ratings:
    +949
    You don't need the semicolon for the if and else statements.

    Code:
    if (40 > 39)
    {
        console.log("I am right");
    }
    else (40 < 39)
    {
        console.log("I am wrong");
    }
     
  3. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
    It worked! Thanks for the help!
     
  4. Jetscat

    Jetscat Builder
    Builder ⛰️ Ex-EcoLeader ⚜️⚜️⚜️

    Joined:
    Oct 8, 2011
    Messages:
    4,060
    Trophy Points:
    44,490
    Gender:
    Male
    Ratings:
    +993
    Your using code academy. :p

    That's what I used.
     
  5. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
  6. rockboy2000

    rockboy2000 Mayor
    Mayor ⛰️⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Oct 19, 2012
    Messages:
    1,335
    Trophy Points:
    50,410
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +310
    That's what we all used.
     
  7. vdubmastertech

    vdubmastertech Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Mar 7, 2012
    Messages:
    634
    Trophy Points:
    28,190
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +150
    Don't put your variable names in double quotes when you call them in a function.

    You only want the first 3 letters so it would be .substring(0-2) , this is because the first letter in the string is actually "0" second is "1" etc.
     
    #7 vdubmastertech, Sep 2, 2013
    Last edited: Sep 2, 2013
  8. RyanJF1

    RyanJF1 Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Jul 1, 2012
    Messages:
    6,464
    Trophy Points:
    47,990
    Gender:
    Male
    Ratings:
    +949
    When something is in "", then it is considered a string. It should just be myCountry.

    Code:
    var myCounty = ("United States")
     
    console.log(myCountry.length);
     
    console.log(myCountry.substring(0-2));
     
    #8 RyanJF1, Sep 2, 2013
    Last edited: Sep 2, 2013
  9. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061


    Thank you again!
     
  10. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
    Code:
    var myCountry = ("United States")
    console.log(myCountry.length);
    console.log(myCountry.substring(0,3));
    This wound up being the correct code, but thank you!
     
  11. vdubmastertech

    vdubmastertech Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Mar 7, 2012
    Messages:
    634
    Trophy Points:
    28,190
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +150
    You're welcome. Also if you get stuck just go to the Q&A Forum for that section. It's in the bottom left hand corner. You can usually find the solutions to most of the problems there. If you are like me you probably understand the lesson better by seeing the completed code first and then breaking it down in your head to understand what each part does.
     
  12. vdubmastertech

    vdubmastertech Builder
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️

    Joined:
    Mar 7, 2012
    Messages:
    634
    Trophy Points:
    28,190
    Gender:
    Male
    EcoDollars:
    $0
    Ratings:
    +150

    Yes that's actually correct. Sorry I always forget substring actually uses the last number as the "cut-off" position.
     
  13. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
  14. pdgwien

    pdgwien Builder
    Builder ⛰️ Ex-Resident ⚒️

    Joined:
    Sep 1, 2013
    Messages:
    17
    Trophy Points:
    25,130
    Gender:
    Male
    Ratings:
    +0
    Again, no semicolons after if or else.

    Code:
    if (feedback > 8) {
       console.log("Yay!");
    } else {
       console.log("Nay!");
    }
    
     
  15. chocolatecheese1

    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Jan 9, 2013
    Messages:
    564
    Trophy Points:
    28,390
    Gender:
    Male
    Ratings:
    +333
    EEWWW WHAT LANGUAGE IS THIS?! It looks disgusting... #Java
     
  16. Xslare

    Xslare Builder
    Builder ⛰️ Ex-Mayor ⚒️⚒️

    Joined:
    Jun 24, 2013
    Messages:
    127
    Trophy Points:
    25,690
    Ratings:
    +44
    #16 Xslare, Sep 19, 2013
    Last edited: Sep 19, 2013
  17. Nelsin

    Nelsin Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Feb 24, 2012
    Messages:
    1,340
    Trophy Points:
    29,340
    Ratings:
    +175
    It isn't java as codeacademy doesn't have Java
     
    #17 Nelsin, Sep 19, 2013
    Last edited: Sep 19, 2013
  18. JamieSinn

    JamieSinn Retired Lead Administrator/Developer
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Jun 4, 2011
    Messages:
    5,509
    Trophy Points:
    78,090
    Gender:
    Male
    Ratings:
    +4,583
    Looks like JavaScript to me
     
  19. Dccciz

    Dccciz Nicememer55
    Builder ⛰️ Ex-Tycoon ⚜️⚜️⚜️ Premium Upgrade

    Joined:
    Mar 8, 2013
    Messages:
    2,829
    Trophy Points:
    50,090
    EcoDollars:
    $0
    Ratings:
    +2,061
    It's Java
     
  20. Nelsin

    Nelsin Builder
    Builder ⛰️ Ex-President ⚒️⚒️

    Joined:
    Feb 24, 2012
    Messages:
    1,340
    Trophy Points:
    29,340
    Ratings:
    +175
    It has it! I never knew