Hi Jacques1,
I have written this code for a biorhythm calculator but I can't figure out why it doesn't work, would you be able to take a look and see if you can find the problem?
It would be greatly appreciated, thank you.
<html>
<head>
<script>
var months = 'janfebmaraprmayjunjulaugsepoctnovdec';
var PI = 3.14159265358979323846;
var msPerDay = 1000*60*60*24;
var interllectualCycle = 33;
var emotionalCycle = 28;
var physicalCycle = 23;
var birthYear = parseInt(prompt( 'Enter year of birth as a 4 digit integer' ));
var birthMonth = prompt( 'Enter name of month of birth' );
//request month of birth
var pos = months.indexOf(birthMonth.substring(0, 3)
.toLowerCase() );
var posMonth = pos / 3;
//alert( 'Month number: ' + pos );
//convert month to number
var numberInString = posMonth;
var numberMonth = new Number(numberInString);
// alert(numberMonth);
var birthDay = parseInt (prompt('Enter day of birth as an integer'));
//enters birthdate into string
var userBirthday = new Date(birthYear, numberMonth, birthDay);
//alert ('' + userBirthday);
//date object created for current date
var currentDate = new Date();
// alert ('' +currentDate)
//creating users age in milliseconds
var msSinceBirth = currentDate.getTime()- userBirthday.getTime() ;
// alert ('' +msSinceBirth);
//creating users age in days
var userMsDays = Math.floor(msSinceBirth / msPerDay);
//document.write ('' + userMsDays);
var bioEnergy = (userMsDays * (2 * PI ) / interllectualCycle);
var bioEmot = (userMsDays * (2 * PI) / emotionalCycle);
var bioPhy = (userMsDays * (2 * PI) / physicalCycle);
//Biorhythm energy levels output
document.write('You have been alive' + userMsDays + 'days');
document.write('<h1>"Your biorhythm energy levels are :-"</h1>');
document.write('<ul>');
document.write('<li><font color="green">intellectual:</font></li>' + [Math.sin(bioEnergy).toFixed(1)]);
document.write('<li><font color="red">emotional:</font></li>' + '' + [Math.sin(bioEmot).toFixed(1)]);
document.write('<li><font color="blue">physical:</font></li>' + [Math.sin(bioPhy).toFixed(1)]);
document.write('</ul>');
</script>
</head>
</html>