javascript - Is there a more efficient way to write this function? -
function month(num) { if (num == 1) { return "january"; } else if (num == 2) { return "feburary"; } else if (num == 3) { return "march"; } else if (num == 4) { return "april"; } else if (num == 5) { return "may"; } else if (num == 6) { return "june"; } else if (num == 7) { return "july"; } else if (num == 8) { return "august"; } else if (num == 9) { return "september"; } else if (num == 10) { return "october"; } else if (num == 11) { return "november"; } else if (num == 12) { return "december"; } else { return false; } }
jquery/javascript.
yes, use month number index array of strings (month names).
Comments
Post a Comment