Originally Posted by sonya1m
Hi again Glenn,
This is what I came up with and it seems to work:
var months = 'janfebmaraprmayjunjulaugsepoctnovdec';
var Pl = 3.14159265358979323846;
var milliseconds = 1000*60*60*24;
var interllectualCycle = 33;
var emotionalCycle = 28;
var physicalCycle = 23;
var birthYear = prompt( 'Enter year of birth as a 4 digit integer');
//alert('Your year of birth is '+ birthYear);
var birthMonth = prompt( 'Enter the name of the month of birth' );
var pos = months.indexOf( birthMonth.substring( 0, 3 ).toLowerCase() );
//alert( 'Month number: ' + ( 1 + pos / 3 ) );
var birthDay = prompt( 'Enter day of birth as an integer ');
var yearString = birthYear;
var monthNumber = pos;
var dayString = birthDay;
//the date object is created like so:
var myBirthday = new Date(yearString - 1, monthNumber, dayString);
alert ('myBirthday' + myBirthday);
//now a date object is contained in the variable called myBirthday
Does it look the way it should?
Simple testing ought to reveal that it does not
When I enter my birthday the year and the month are both displayed wrongly. Why do you subtract 1 from the year?
var monthNumber = pos; // is simply silly - December comes out as month 33!
Prompts are long obsolete. You should eliminate them. Have you not noticed that the initial value is displayed as "undefined"?
Why do you ignore glenngv's advice:-
Why do you prompt for month name instead of just month number? Typing text is more error prone compared to numbers. If you prompt for numeric birth month, then the date of birth could be easily created.
Thre is no point in coming to this forum for expert help and then disregarding the advice offered.