Avatar

Correct answer by
Level 10

You're close. But the script can still be shorter.

var nDay = new Date().getDate(),

r = "";

if (nDay == 1 || nDay == 21 || nDay == 31) {

r += "st";

} else if (nDay == 2 || nDay == 22) {

r += "nd";

} else if (nDay == 3 || nDay == 23) {

r += "rd";

} else {

r += "th";

}

this.rawValue = nDay + r;

View solution in original post