Learning to code. Page 5

  • Page

    of 6 First / Last

  • mal 3 May 2012 14:06:00 21,930 posts
    Seen 5 hours ago
    Registered 12 years ago
    Hah. I remember in the mid 90s we had the computer lab with a passably specced SparcServer5 running everything, but most of the time I couldn't be bothered with the trek to the computer center, so I used to telnet into the campus wide system from the hall terminals, and from there telnet into the computer lab machine. And then you could always grab a quick pint from the bar while you were waiting for something to compile.

    Cubby didn't know how to turn off sigs!

  • Mr-Brett 21 May 2012 20:24:31 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    These codcademy courses really are a bit hit or miss. They're about 40% not enough explanation, 40% too much (like just giving you the exact answer and thus not teaching you much) and about 15% spot on, with the last 5% being a complete cluster-funk.

    I can't really complain since it's free education but it's frustrating to see what are often basic mistakes causing you to have to go to the forums and find that your code was fine it's actually the exercise that's broken.

    Portable view - Never forget.

  • RedSparrows 21 May 2012 20:28:39 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    Yeah, there's a fair bit wrong with it.

    Still, a good service given it's free.
  • skuzzbag 21 May 2012 20:33:50 5,482 posts
    Seen 11 hours ago
    Registered 10 years ago
    What are you learning?
  • Mr-Brett 21 May 2012 20:37:54 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    Javascript, when I'm comfortable with it I'm considering learning C# with a real IDE.

    Portable view - Never forget.

  • RedSparrows 21 May 2012 21:16:27 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    So you have a website, set up like thus:

    Link Link Link Link

    Picture

    That's it. Four links along the top, an image beneath, centred.

    What is it called when, if you click on a link, it simply changes the photo beneath, and displays text next to it?

    I think I can manage the code, eventually - I just have no idea what that's called by web devs etc.
  • Mr-Brett 21 May 2012 21:47:38 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    "Image gallery" is probably what you're after, I use a JSQuery one on my site, I might even understand it now I've done some JS lessons :)

    Portable view - Never forget.

  • RedSparrows 21 May 2012 21:49:33 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    Ta. Will work from that and see where it takes me. All I want is different pictures for each link, and the explanatory text alongside - all on one page. No faffing with other pages.
  • mal 21 May 2012 22:02:56 21,930 posts
    Seen 5 hours ago
    Registered 12 years ago
    The general event of something happening in Javascript when the mouse is over an icon or other object is known as a mouseover event. The most common example of mouseover handling code is code that changes the image under the mouse when the mouse is over the image, so you just need to add text to that.

    Cubby didn't know how to turn off sigs!

  • RedSparrows 21 May 2012 22:10:12 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    Thanks mal, will look into that - sounds more flexible than the image gallery.
  • RedSparrows 21 May 2012 22:11:22 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    Thanks mal, will look into that - sounds more flexible than the image gallery.
  • Mr-Brett 21 May 2012 22:49:22 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    I don't know about more flexible but I'm sure it's a lot easier :)
    I used to use mouseovers in Dreamweaver years ago, I completely forgot that they were js.

    Portable view - Never forget.

  • AcidSnake 21 May 2012 23:20:09 7,136 posts
    Seen 14 hours ago
    Registered 8 years ago
    Otherwise the onclick event...JS again...
    Pretty easy to have a click or hover change the picture of an element (div or what have you)...
    If you need a sample piece let me know...It can be done in just a few lines of code really...

    AcidSnake - He can't see your sig, avatar, images or vids and talks about himself in the third person because he's proper old-skool...UID 24017

  • RedSparrows 21 May 2012 23:33:09 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    A sample piece would be lovely. I am still a noob at this...
  • Twin_snakes 21 May 2012 23:50:35 2,191 posts
    Seen 7 months ago
    Registered 5 years ago
    Something like this should do it:
    ocu/ment.getElementById("Image").setAttribute("src", "Image1.jpg");" > Image 1
    ocu/ment.getElementById("Image").setAttribute("src", "Image2.jpg");" > Image 2




    It's been years since I've done JS so forgive me if it doesn't work


    Edit: Eurogamer needs to get some code tags

    Edited by Twin_snakes at 23:54:52 21-05-2012
  • Mr-Brett 27 May 2012 09:15:31 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    Just when I get my head around for loops I move on to recursion and get thoroughly confused again.

    Portable view - Never forget.

  • mal 27 May 2012 09:24:27 21,930 posts
    Seen 5 hours ago
    Registered 12 years ago
    I think anyone who considers coding professionally should learn at least one functional language. Really forces you to get your head around recursion, as well as a few other featurea that are just starting to turn up in more traditional languages.

    Cubby didn't know how to turn off sigs!

  • sport 27 May 2012 09:32:43 12,043 posts
    Seen 7 hours ago
    Registered 8 years ago
    Honestly guys, if you want to do JavaScript programming, learn JQuery. It's basically just wrapper classes built on JavaScript. It's pretty much the de facto standard now for implementing js functionality on websites.
  • mal 27 May 2012 10:13:58 21,930 posts
    Seen 5 hours ago
    Registered 12 years ago
    When reading my last post here, or perhaps any of my posts in here,, it's worth considering that I don't think of copying and pasting a bit of javascript into your website to be actual coding. Nothing wrong with it, of course, just not what the title of the thread brings to mind.

    Cubby didn't know how to turn off sigs!

  • DUFFKING 27 May 2012 13:53:09 6,487 posts
    Seen 8 hours ago
    Registered 7 years ago
    Mr-Brett wrote:
    Just when I get my head around for loops I move on to recursion and get thoroughly confused again.
    Google it ;)
  • RedSparrows 27 May 2012 16:48:44 20,747 posts
    Seen 6 hours ago
    Registered 7 years ago
    mal wrote:
    When reading my last post here, or perhaps any of my posts in here,, it's worth considering that I don't think of copying and pasting a bit of javascript into your website to be actual coding. Nothing wrong with it, of course, just not what the title of the thread brings to mind.
    I an doing both - c/p is for immediate effect on one small thing ;)
  • Mr-Brett 7 Jul 2012 11:00:39 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    Morning chaps, I've been stuck on one of the codecademy lessons for a few days and since it seems to usually take a week before anyone answers on the forums there I was hoping you guy might be able to help.

    This is the lesson.
    Here's my code.

    If you paste that into the ide then you'll get:

    "TypeError: Object # has no method 'printHand'
    That's correct! Next Exercise"

    So oddly it's passing it but that's not much use if the code is actually broken somehow. Any ideas? .

    Edited by Mr-Brett at 11:03:39 07-07-2012

    Portable view - Never forget.

  • monkehhh 7 Jul 2012 13:00:57 3,124 posts
    Seen 6 hours ago
    Registered 5 years ago
    @Mr-Brett

    There's some mismatches in style / case and some general weirdness where you're creating cards, so a one-line fix isn't really possible. Here's my attempt - see where it does stuff different to yours.

    Edit - code edit :)

    Edited by monkehhh at 13:07:19 07-07-2012
  • Mr-Brett 7 Jul 2012 13:31:42 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    Thanks monkehhh, interesting stuff!

    So one of the main changes is using this.something = function() instead of function = something(). I have found the public/private and when to use what a bit confusing. I assume the 'this.' or 'var' methods are for functions inside of functions then?

    Portable view - Never forget.

  • monkehhh 7 Jul 2012 14:20:03 3,124 posts
    Seen 6 hours ago
    Registered 5 years ago
    I could follow what you'd tried to do, the general flow of our code is pretty similar - just getting caught up in the implementation :)

    Anything inside the Card class declared using "this" can be accessed outside the class (eg. the three get functions), anything using "var" or "function blah()" can only be accessed by functions within the class (eg. suit, number). I think recommended practice is to have all your variables within a class to be private and then to provide public functions for accessing them.

    The way I did the dealing means I get a new Card object back everytime I use "deal()".

    Also, you were calling playAsUser() at the end which was messing stuff up as the website that tests your code calls it for you.

    And check that you're not mixing cases (cardArray / CardArray / Cardarray) :)
  • Mr-Brett 7 Jul 2012 17:22:14 12,676 posts
    Seen 8 hours ago
    Registered 8 years ago
    Ah, thanks for explaining. I think I've got my head around the public/private stuff now.

    The way you handled deal() is a lot nicer, I've copied that one :)

    The playAsUser() thing I was using the scratchpad but you're right I shouldn't have had there in main section.

    Cases trip me up all the time so I normally try and put more effort into finding them, I'm surprised I missed those with the cardArray.

    I'm still having some trouble though, I've updated the code I previously linked. I'm getting the confirm dialog now and it doesn't say undefined any more but it only ever seems to say "8of suit1", ignoring the crudeness of the data representation there, why would it come up with the same result every time?

    This might be a good time to ask; is there a recommended desktop IDE for JS?

    Portable view - Never forget.

  • monkehhh 7 Jul 2012 17:40:28 3,124 posts
    Seen 6 hours ago
    Registered 5 years ago
    The position of "return string;" is making that happen, you want it to be returned once the for loop is finished and the string is complete.

    Not sure about IDE stuff - at this stage a text editor that can simply highlight JavaScript would probably be preferable, for me. Notepad++ or something similar maybe? My only real IDE experience is using Eclipse and Netbeans for Java development, I settled on Eclipse in the end.
  • gammonbanter 16 Oct 2012 22:32:30 1,415 posts
    Seen 19 hours ago
    Registered 6 years ago
    What's a good Java IDE - obviously the more free the better. Enjoying code academy, apart from the broken parts.
  • gammonbanter 16 Oct 2012 22:36:56 1,415 posts
    Seen 19 hours ago
    Registered 6 years ago
    Ok, netbeans or jcreator? I'm picking up the peices from my degree 10 years ago, so need to be handled with care intially.
  • monkehhh 16 Oct 2012 22:41:09 3,124 posts
    Seen 6 hours ago
    Registered 5 years ago
    Netbeans or Eclipse for me, from when I did some LWJGL stuff. Currently got Eclipse installed.
  • Page

    of 6 First / Last

Log in or register to reply