I am trying to call a variable in an alert with an If then else statement.
I am creating the global variable currentmonth on page load. I tested that a value is loading into currentmonth and it is working.
I am also creating the global variables (datejanuary through datedecember) on page load. I have also tested those values and they are working.
Basically what I'm wanting to do is get the current month and compare it to a value from an array and display a message in an alert. For example, the message for January would be "Mini Golf – the golf may be mini, the competition will be big. To the winner go the spoils!" for February the message would be "Hike – it’s not about the destination, it’s about the journey."
Below is the function I created for this and I can't get it to work. What am I missing?
<script>
function dateMonth()
{
var currentdate = "";
if (currentmonth == "January")
{
currentdate = datejanuary;
}
else if (currentmonth == "February")
{
currentdate = datefebruary;
}
else if (currentmonth == "March")
{
currentdate = datemarch;
}
else if (currentmonth == "April")
{
currentdate = dateapril;
}
else if (currentmonth == "May")
{
currentdate = datemay;
}
else if (currentmonth == "June")
{
currentdate = datejune;
}
else if (currentmonth == "July")
{
currentdate = datejuly;
}
else if (currentmonth == "August")
{
currentdate = dateaugust;
}
else if (currentmonth == "September")
{
currentdate = dateseptember;
}
else if (currentmonth == "October")
{
currentdate = dateoctober;
}
else if (currentmonth == "November")
{
currentdate = datenovember;
}
else
{
currentdate = datedecember;
}
{
vex.dialog.alert(currentdate);
}
</script>