SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Orange county
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Student Needs Help

    If any of you are patient tutors or masters of JavaScript that would be willing to help me out through my semester I need your help. This is my first time taking a programming class, I'm used to html but I am so frustrated in my class right now that I need all the help I can get. This mess just seems like a foreign language that I'm just not able to make happen when it comes to doing an assignment in class after the lecture. If anyone is good at breaking things down and helping me "get it" that would be excellent. This is something I really want to understand and I don't like not understanding. I'm so baffled that I don't even know how to ask the proper questions to break down my confusion. I ask questions and I still feel dumbfounded by my instructor's answer.

    Please Help.

    We are working from the book "Mastering JavaScript and JScript" by James Jaworski and we are on chapter three. We have gone over functions, variables, return statements (today's class)...and I'm just absolutely lost.

    Natalie

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    If you write down your questions here, I am sure that there is someone that can help you. I think that I am quite skilled at Javascript but I am not the only one.

    Yours, Erik.

  3. #3
    SitePoint Zealot MacRankin's Avatar
    Join Date
    Sep 2002
    Location
    London
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You couldn't do much worse than going to my JavaScript tutorial: JavaScript Stuff

    I'm not a JavaScript guru, I'm just somebody like yourself who's trying to visualize what JavaScript is and how I can manipulate it. There maybe some issues regarding the sequence of keywords in my tutorial, but at least you'll be able to print the whole thing out. It's not finnished, and I have other things yet to write about regarding images and arrays. But if you can get a handle on it early on then you'll be able to seek out more professional resources that there are on the web.

    There's a lot of JavaScript that I don't understand, and to be honest I'm not altogether sure that I want to understand. Still, the way that I discover how to do JavaScript is to basically stumble over my mistakes. Most of the time it's a case of "I wonder what will happen if I do this?"

    If my site is of no use to you then do try this site: EchoEcho Quick Reference There's also a JavaScript tutorial on this site somewhere.

    P.S I know that time may seem to be your enemy right now, but the way that I learn how to do stuff is to become familiar with stuff over time, and in that way it's not so much about learning bucket-loads, but more about recognition.

    P.P.S. I really hope it goes well with you.
    We Brits do things differently. But we still get shot at.

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Start by writing down the "big steps" in the general sequence of events you need to do.

    Then look at each big step and break it down into a series of smaller steps.

    Repeat as necessary, until you can write the lines of code when it can't be broken down to anything simpler

    eg calculate scores
    update postion
    start next level or new game

    which then breaks down into

    calculate points for dead aliens
    calculate points for spare bombs
    calculate points for dead spaceships
    calculate bonus points
    calculate total score

    and

    find new position in position list
    insert new position
    delete old position
    etc

    and

    check player still alive
    if alive increment to next level
    else start new game

    etc

    When you get to a simple level / statement, you just write the code. But you know most of the steps before you start writing the code, so you tackle each small problem, knowing that the rest will be okay when you get to it.

    This is called writing pseudocode, or step wise refinement or structured english.

    It is a simple way of working out what you will need to do before you attempt at random to guess an answer.

    I started the first programming class I ever took three weeks late and was stuck, so just wrote down these "big steps" while everyone else typed away like mad, and then attempted to write the code. Thing was, I always finshed before the guys who rushed in, including those who had programmed a little bit before taking the course. Later on we got lessons on how to write pseudocode, and I'd been doing it for weeks. The others stuck with their dive in head first approach, and tried to write teh pseudocode after they'd finished the programs (a requirement for the course was to hand in your pseudocode). That was a bit like trying to build a house, then draw up a blueprint afterwards. Cos pseudocode is your blueprint. Try it, it does work.

    You could work on the above "calculate scores" with no knowledge of how to work out the new position and get it correct. You could work on points for dead aliens and dead spaceships without knowing how to do the bonus points as well.

    Oh, and try reading a text book. You know, these paper based interface things. Books have to be accepted by a publisher, a technical editor, a bookshop buyer, and your lecturer before you get told "try this book", while a web page can be written by anyone, with lots of mistakes. (Books are kept in the library, that big building most students ignore for ages...)

  5. #5
    SitePoint Member
    Join Date
    Sep 2004
    Location
    Orange county
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am reviewing what was done in class on saturday in my source code and i'm not sure why (what you see is the instructor's revision) everything was defined and used in the header.

    <html>
    <head><title> return statement </title>
    <SCRIPT LANGUAGE= "JavaScript"><!--
    function factorial(n) {
    var sum = 1
    for(i=1;i<=n;++i)
    sum *=i
    document.write("The sum is " +sum)
    return sum
    }
    // -->
    </SCRIPT>
    </head>
    <SCRIPT LANGUAGE= "JavaScript"><!--

    factorial(5)

    // -->

    </SCRIPT>
    </BODY>
    </HTML>

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nattynico
    I am reviewing what was done in class on saturday in my source code and i'm not sure why (what you see is the instructor's revision) everything was defined and used in the header.

    <html>
    <head><title> return statement </title>
    <SCRIPT LANGUAGE= "JavaScript"><!--
    function factorial(n) {
    var sum = 1
    for(i=1;i<=n;++i)
    sum *=i
    document.write("The sum is " +sum)
    return sum
    }
    // -->
    </SCRIPT>
    </head>
    <SCRIPT LANGUAGE= "JavaScript"><!--

    factorial(5)

    // -->

    </SCRIPT>
    </BODY>
    </HTML>
    Hi,

    What's your question? There are lots of people that can help you, but you have to let them know what is confusing you.

    Is it: what does '<html>' do?
    Is it: What does this mean: '<script language="javascript"><!--'
    Is it: What's a function?
    Is it: What's a factorial?
    Is it: I don't get how for-loops work?

    Essentially, the script you posted is what's called a 'function'. A function is just a set of calculations you group together. Then, in the body of the html, the function is called. (Note: there is no opening BODY tag). When you call a function, it performs the set of calculations you grouped together.

    There's also no semicolon after:

    factorial 5

    Javascript statements end with semicolons. Even though it might not always be necessary, it's good practice.

    Is your textbook no good? If you can't understand the teacher's lessons, maybe you should read the text?

    Go Anteaters.
    Last edited by 7stud; Sep 22, 2004 at 09:58.


Bookmarks

Posting Permissions

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