1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Learning JavaScript coding, whats wrong with this code?

Discussion in 'Software Development' started by turbow5, Jun 18, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    Ok got all that done. Think I'm loosing it with this stuff after each lesson. This is how to log the length of the word right?
     

    Attached Files:

  2. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    You're close. The problem is with line 3. Again, think about the colours. You need to set the value of myJob to the string "Computers".

    I should say though, while they may seem useless because the computer doesn't read them, it is very much worth your while using comments that are as descriptive as they can be. They don't cost anything except a moment of time, and it will help you when you or someone else has to come back and read your code some time in the future.
     
  3. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    If/then statements again. I don't see what's wrong with the last line.
     

    Attached Files:

  4. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    Funny how people get all this fancy stuff sorted out, but then forget basic first grade arithmetic.
    What is 2 + 2 ? ;)
     
  5. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    I wanted a false to be first this time. Does it always have to be true first then false?
     
  6. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    How do you expect the computer to know that you wanted it to do the first thing if it were false?
    Yes, you have to write the true section first.

    If someone said "If you have a ticket stand in line A, otherwise stand in line B", that would clearly mean that people who do have tickets take the first option, and people without tickets take the second option. It's exactly the same in this script.
     
  7. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    I did not log the correct string to the console...:confused: This one stopped me in my tracks. I thought you suppsoe to log them both?
     
  8. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    Failed to upload image.
     

    Attached Files:

  9. Ent

    Ent Josiah Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,408
    I can't see what's wrong there. Sorry.
     
  10. ckphilli

    ckphilli

    Joined:
    Apr 29, 2006
    Messages:
    4,384
    Don't know Turbo. I just tried it in codeacademy with no problems. Here's what I did:

    Code:
    if(2+2 > 4)
    {
        console.log("test");
    }
    else
    {
        console.log("I finished my first course!");
    }
    
    Maybe you have an extra space somewhere? I tried to repeat your error and can't. Regardless, I wouldn't sweat over this...move forward.:)
     
  11. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    I couldn't get it either, I had to copy and paste yours. Am I done with this? there's no next section. If I am done can I start making programs/mods/whatever else?
     
  12. ckphilli

    ckphilli

    Joined:
    Apr 29, 2006
    Messages:
    4,384
    No, that was just the intro. There are several other JavaScript tutorials on that site. :)
     
  13. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    Yeah after you replied I got a email for a new course.
     
  14. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    I'm multitasking to much to look this up at the moment, sorry but when do threads usually close down from no responses?
     
  15. turbow5

    turbow5 Thread Starter

    Joined:
    Jan 2, 2012
    Messages:
    490
    Never mind I found it. But for the looping part of JavaScript is this how you loop?
     

    Attached Files:

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1057635