function getMonthName(monthNumber) {
const date = new Date();
date.setMonth(monthNumber - 1);
return date.toLocaleString([], { month: 'long' });
}
Post funny things about programming here! (Or just rant about your favourite programming language.)
I would expect the month to increment by one and the day to be clamped to the valid days for the month.
That’s precisely what I’d expect as well, and what APIs in languages like Java do.