0

Hello friends,

I have to create a dense array called "monthName that contains the names of all 12 months starting with "January" So far, I have created this:

function showDate(thisDate) {
    var thisWDay=Today.getWeekday();
    var thisDay=Today.getDate();
    var thisMonth=Today.getMonth();
    var thisYear=Today.getFullYear();
    var variable=new Array(monthName[0]="January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");}

I am really not sure if I did it right or not, and I need someone's input. Thank you. :)

2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by thedancingbug
0

Not sure what you mean... How about this...

var monthName = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

Would that be simplier?

0

It told me to set up the array so that monthName[0]="January"

I was wondering where I would place that. :\

0

OK, so how about this...

var monthName = new Array(12)
// the current value of monthName is [undefined, undefined, ...]
monthName[0] = "January"
// when you check the value of the array, it will be...
// ["January", undefined, undefined, ...]

I'm not sure how much knowledge you have about array data type. The first line is to declare an array data type to the variable named monthName. At the same time, the declaration assign the array size (12). Once declare an array with the size, the default value of each element the array is holding is undefined. Then the second line assigns value "January" to the first index (0) of the array.

0

Right, that makes a little more sense. The book I am learning from (I'm doing homework for my own benefit) was a bit vague in explaining dense array, but when you arranged it like that it made more sense. Thank you.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.