Thread: Date Object !

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    100
    Rep Power
    0

    Date Object !


    Code:
    function getSeason(obj){
    	var month = obj.getMonth();
    	var day = obj.getDay();
    	if (mon < 2 || (mon == 2 && day < 20)){
    	return "winter";	
    	}
    		else if(mon < 5 || (mon == 5 && day <21)){
    			return "spring";
    			}
    		else if(mon < 8 || (mon == 8 && day <23)){
    			return "summer";
    			}
    		else if(mon < 11 || (mon == 11 && day <22)){
    			return "Fall";
    			}
    			else{
    			return "winter";
    			}
    }
    
    var today = new Date();
    document.write(getSeason(today));

    why this code is not running ? not even in Alert(); function. It dont display anything just nothing
  2. #2
  3. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,184
    Rep Power
    492
    Yeah, you set "month" to the month, then in your comparisons, you use "mon" ...

    var month = obj.getMonth();
    if (mon < 2
    Last edited by badger_fruit; December 16th, 2013 at 10:01 AM.
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    100
    Rep Power
    0
    aaaaaaaaaaaaaaaaaaaaaa programmmingggggggggggg
  6. #4
  7. Confused badger
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Mar 2009
    Location
    West Yorkshire
    Posts
    1,184
    Rep Power
    492
    Hahaha, yeah, it's great isn't it!
    Did you fix it now?
    "For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
    - George Orwell, 1984
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    100
    Rep Power
    0
    yeah got it ... know any book for OOP in JAVASCIRPT ??
    badger_fruit

IMN logo majestic logo threadwatch logo seochat tools logo