Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Codecademy-Programmers Please Help!

  • 28-07-2012 03:51PM
    #1
    Registered Users, Registered Users 2 Posts: 627 ✭✭✭


    Hi all you programmers out there, please help me! im stuck on this problem on codecademy and cant find a solution? If you could help me id really appreciate it!
    Cheers


Comments

  • Registered Users, Registered Users 2 Posts: 15,079 ✭✭✭✭Malice


    What have you tried so far? Post your code and it'll be easier to see where you're going wrong.


  • Moderators, Computer Games Moderators Posts: 10,462 Mod ✭✭✭✭Axwell


    for ( var i=99; i<=101; i++ ) 
    
    if (i%2 == 0)
    {
    print("Even!")  
    }
    else
    {
    print("Odd!")
    }
    
    


  • Registered Users, Registered Users 2 Posts: 2,746 ✭✭✭Darwin


    Have you tried the hint button which talks about the modulus (%) operator? I presume you understand how if/else selection works? Here's two things to think about: If the result of (i % 2) is 0, what does that tell you about i? How do you perform an equality test inside an if statement?


  • Registered Users, Registered Users 2 Posts: 627 ✭✭✭kerryked


    hey guys thanks for the really quick responses! Axwell, your answer worked like a charm! what i had was

    for ( var i=99; i<=101; i++ ) {
    if (i%2=0, console.log("Even!))
    else console.log("Odd!")

    as they say, close but no cigar!..ah well..my curly bracket things were all over the place, i dont think i even had any! i also forgot that you have to have like 3 equals signs...

    Anyways cheers for ye're help lads!


Advertisement