Jump to content

First JavaScript time thing


Guest FirefoxRocks

Recommended Posts

The code initiates just fine, however if you are looking at the output and expecting something else, than probably there is some error hidden in there. Code can often run fine and give you a result, but if it's not your desire, then possibly something is up.On a note, in your first if statement, you have a date variable, and you try to get values from it, but you are arbitrarily pulling them as if they were actual properties of the object, when in fact you should be using functions to grab them. Just add "()" to them. Also, I don't believe it is required, but it's good practice and ensures against possible errors; you should put a semi-colon at the end of each line statement. If nothing else, it provides organization. Though JS is flexible enough in how it is interpretted through a browser's engine that it doesn't matter, so it's a matter of choice on your part.Lastly, this is also a matter of style, but it provides for organization. When involving multiple and complex conditional statements, you should seperate each pairing. It's no syntatical difference whether or not you use parentheses, but it helps to keep things straight and which operators are evaluated first. Other than that, the code is without visible fault. Keep up the practice.

Link to comment
Share on other sites

Guest FirefoxRocks

There actually are output errors in the JavaScript, the weekend code isn't running properly. Where do I insert the parenthesis?

Link to comment
Share on other sites

Your code is working ok for me in Firefox and Internet Explorer.About the parenthesis, it's this:You wrote d.getDay and it should be d.getDay(), because getDay isn't a property, it's a method.

Link to comment
Share on other sites

That's the problem with JS. It's such a loosely interpreted language that you can get away with some pretty nasty faults in how you code something. Just because it runs doesn't mean it runs properly. Side note, neither Opera or Safari spotted errors. Just be careful and your code should be in good shape.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...