Conditionals: What Day Is It

Conditionals: What Day Is It

<script type="text/javascript">
 function whatDayIsIt(){
  var ValidDays = new Array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
  ask_the_user = prompt('What day is it today?');
  day_of_the_week_number = ValidDays.indexOf(ask_the_user);
  if(day_of_the_week_number<0){
   alert('You have not entered a valid day. Please check and try again. Your day must start with a capital letter.');
   whatDayIsIt();
  }
  else{
   if(ask_the_user=="Friday"){
    alert('Yay! It is nearly the weekend!');
   }
   else if (ask_the_user=="Saturday" || ask_the_user == "Sunday"){
    alert('Enjoy the Weekend!');
   }
   else{
    day_of_the_week_number+=1;
    day_weekend_starts = 6;
    days_until_the_weekend = day_weekend_starts - day_of_the_week_number;
    alert('Do not fret! Only '+days_until_the_weekend+' days until the weekend!');
   }
  }
 }
</script>
Comments are closed.