function fun(day) { var data = new Date(); data.setDate(data.getDate()+day + [0,6,5,4,3,2,1,0][day]) return data.toLocaleDateString() } alert(fun(2));