I have a function based on a lot of if/else statements. The function works there is no problem with that but I wonder is there a shorter way to rewrite this?
month = get_month(field.value); //this is inside another function
function get_month(m){ if(m==='January'){return'01';} else if(m==='Febuary'){return'02';} else if(m==='March'){return'03';} else if(m==='April'){return'04';} else if(m==='May'){return'05';} else if(m==='June'){return'06';} else if(m==='July'){return'07';} else if(m==='August'){return'08';} else if(m==='September'){return'09';} else if(m==='October'){return'10';} else if(m==='November'){return'11';} else if(m==='December'){return'12';}}
I have seen and used this before but I don't know if would work on this scale:
var x = y !== undefined ? y : 1;