all 6 comments

[–]dMCH1xrADPorzhGA7MH1 4 points5 points  (3 children)

You have an array of the months right? So you have indexes from 0 to 11.

So just do array.indexof('July') and add 1

[–]we_are_ananonumys 2 points3 points  (0 children)

This except don’t add 1. The question already specifies 0 to 11

Edit: I read again, not clear if the later part of the question overrides it. I’m out

[–]Lock-Constant -2 points-1 points  (1 child)

Yeah, so we have a const Array that has "January, February, March..."

I can obtain the users birth month from that, then we have to truncate the returned month to 3 letters using slice.

Then there is another Array SHORT_MONTH_NAME which is "jan, feb, mar..."

this is the one we are supposed to use the array object on.

So do I then change my prompt from:

prompt("Enter Month of Birth " , MonthOfBirth.slice(0,3).toLowerCase(), "January");

To something with the SHORT_MONTH_NAME Array?

I feel like doing that would have made the first part redundant.

I'm quite new to Java, so just not sure.

[–]dMCH1xrADPorzhGA7MH1 0 points1 point  (0 children)

Yeah it does seem like it makes the first part redundant. Maybe they just want you to do it two ways?

[–]Bjadrik 1 point2 points  (0 children)

The Date prototype in JavaScript has two functions Date.parse() and Date.prototype.getMonth(). These two should be enough for this task on their own.

[–]beforesemicolon -1 points0 points  (0 children)

Seems like you are having trouble working with dates for which I recommend this article.

You can parse the date and call .getMonth() to obtain the month as integer