Guest FirefoxRocks Posted November 17, 2007 Share Posted November 17, 2007 Ok I am practicing my skills with JavaScript and I have made this: http://portal.trap17.com/jstest1.htmlI want people to verify if it works correctly or not. The script is in the code. If you find any error, please tell me as I have very little experience with JavaScript. Link to comment Share on other sites More sharing options...
Ingolme Posted November 17, 2007 Share Posted November 17, 2007 To me it seems to work ok, and my error console returns no errors from the site. Link to comment Share on other sites More sharing options...
SpOrTsDuDe.Reese Posted November 17, 2007 Share Posted November 17, 2007 The code looks fine to me...What is the problem? Link to comment Share on other sites More sharing options...
Shonumi Posted November 17, 2007 Share Posted November 17, 2007 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 More sharing options...
Guest FirefoxRocks Posted November 17, 2007 Share Posted November 17, 2007 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 More sharing options...
Ingolme Posted November 17, 2007 Share Posted November 17, 2007 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 More sharing options...
Shonumi Posted November 18, 2007 Share Posted November 18, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.