Hi everyone! I need some help with this javascript. I just don't seem to understand how to code it properly. The code is suppose to let the user enter which month his birthday is on and which day, then the script would tell the user how many days it is until his birthday. But I don't know how to code that. This is what I need help with: I know that if I count todays ms seconds subtraction with the ms for the users birthday and then convert that to days I will know how many days it's left to the users birthday. This is the code I got so far: var minusEtt = Number( prompt('What month is your birthday (1-12)?','') ); var date = Number( prompt('What day is your birthday (1-31)?','') ); var month = minusEtt - 1 ; // the month - one var nextBirthday = new Date( month, date, 0, 0, 0, 0 ) // month, date, hour, min, sec, ms var todaysDate = new Date(); // Todays date Code (markup):
Okey, I have updated the code. It now looks like this. What have I done wrong that makes the code not to write out? var minusEtt = Number( prompt('What month is your birthday (1-12)?','') ); var date = Number( prompt('What day is your birthday (1-31)?','') ); var month = minusEtt - 1 ; // the month - one var nextBirthday = new Date( month, date, 0, 0, 0, 0 ) // month, date, hour, min, sec, ms var todaysDate = new Date(); // Todays date myDate.getTime(); var skillnad = nextBirthday.getTime() - todaysDate.getTime(); var skrivUt = skillnad / 1000 / 60 / 60 / 24 ; document.write( skrivUt.toString( ) ) Code (markup):