
"You chose July."
"In this month, we celebrate 4th of July."
I don't know how to make the response to the prompt also call the index to the second array and write that second line!
Will you assist me please? Thanks!
Here's the script:
<html>
<head>
<title>months</title>
<script language="JavaScript" type="text/javascript"> <!--
var months = new Array(11)
months[0] = "January"
months[1] = "February"
months[2] = "March"
months[3] = "April"
months[4] = "May"
months[5] = "June"
months[6] = "July"
months[7] = "August"
months[8] = "September"
months[9] = "October"
months[10] = "November"
months[11] = "December"
var dates = new Array(11)
dates[0] = "New Year's Day"
dates[1] = "President's Day"
dates[2] = "St. Patrick's Day"
dates[3] = "Bunny Day"
dates[4] = "Memorial Day"
dates[5] = "Flag Day"
dates[6] = "4th of July"
dates[7] = "Back to School"
dates[8] = "Labor Day"
dates[9] = "Halloween"
dates[10] = "Thanksgiving"
dates[11] = "Ho Ho Ho!"
//-->
</script>
</head>
<body>
<script language="JavaScript" type="text/javascript"> <!--
var response = prompt("Enter a number from 1 to 12 that corresponds with the month: ", "")
if (response < 1 || response >= 12){
alert("That is not a valid choice. Choose another.") }
else {
document.write("You selected " + months[response] + ".") }
var response = i
for (i=0; i<dates.length; i++) {
document.write("This month we celebrate ", + dates[response] + ".") }
//-->
</script>
</body>
</html>
Comment