I have two variables that are strings: month1Digit1 and month1Digit2. Together they make up a the decimal digits of a month (01-12), so month1Digit1 is always either 0 or 1, and month1Digit2 could be any number other than 0. Now I have several of these, as in month2Digit1, etc. I want a function that can determine the name of the month from these variables. But I don't want to write a separate function for each group just because it has different variables. From searching around it looks like I need to do a function with arguments, but I'm not really sure how this works. I tried the following:
var month1Digit1 = "1";
var month1Digit2 = "2";
function getMonthName (month) {
if (month == "1") { month = "January" }
else if (month == "2") { month = "February" }
else if (month == "3") { month = "March" }
else if (month == "4") { month = "April" }
else if (month == "5") { month = "May" }
else if (month == "6") { month = "June" }
else if (month == "7") { month = "July" }
else if (month == "8") { month = "August" }
else if (month == "9") { month = "September" }
else if (month == "10") { month = "October" }
else if (month == "11") { month = "November" }
else if (month == "12") { month = "December" }
}
var orangemonth1 = month1Digit1 + month1Digit2;
getMonthName(orangemonth1);
orangedate = orangemonth1;
Now from this, the value of orangedate should be 'December', no? But when I run this, I get "12" as the value. So the function isn't working. What am I doing wrong?