www.webdeveloper.com
Results 1 to 4 of 4

Thread: Array changing by getDay() method

  1. #1
    Join Date
    Nov 2009
    Posts
    4

    Array changing by getDay() method

    Hi,

    I'm having the hardest time creating this addition to my webpage. Basically all I want is create an array with 7 facts about my page, and then have my page display them one at a time depending on the day of the week.

    If anyone could help me it would be greatly appreciated.

    Thanks,
    Kyle

  2. #2
    Join Date
    Feb 2006
    Posts
    2,927
    Code:
    var A=['a','b','c','d','e','f','g'];
    var q=new Date().getDay();
    alert(A.splice(q))// or document.write,  innerHTML, createTextNode...
    A now contains every thing but the day's choice, which was removed with the splice..

  3. #3
    Join Date
    Nov 2009
    Posts
    4
    Thank you for the help! Are there any alternatives to the splice method? I've never seen splice used in my class before.
    Last edited by Dryst; 12-01-2009 at 04:00 PM.

  4. #4
    Join Date
    Feb 2006
    Posts
    2,927
    You don't need to use splice at all. Just return A[new Date().getDay()],
    and don't use that index again on the same page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles