Random "month & day" with JS Can anyone review this?

setInterval(function() {
var days_array = [31,29,31,30,31,30,31,31,30,31,30,31];
var m = randNum(12);
var m_limit = days_array[m-1];
var d = randNum(m_limit);
$("code").html("day = "+d+"&lt;br&gt;month = "+m);
},1000);
function randNum(limit){var r=Math.floor(Math.random()*limit)+1;return r;}


jsFiddle
function randNum(limit){var r=Math.floor(Math.random()*limit)+1;return r;}


Can be shortened to:

function randNum(limit){return Math.floor(Math.random()*limit)+1;}


You should also declare your variables outside of the setInterval and then set them inside only if you need to (for example, the days_array never changes so only needs to be decalared once and not every second.