Skip to content

Instantly share code, notes, and snippets.

@smith
Created December 31, 2024 16:53
Show Gist options
  • Save smith/bd5c55aaf056ee4d812be8f06bc55075 to your computer and use it in GitHub Desktop.
Save smith/bd5c55aaf056ee4d812be8f06bc55075 to your computer and use it in GitHub Desktop.
Solution to @cassidoo's interview question of the week 2024-12-30
// Interview question of the week (see https://buttondown.com/cassidoo/archive/we-must-adjust-to-changing-times-and-still-hold/)
// ...
//
// This week's question:
// Given a year, return the day of the week for New Year's Day of that year.
//
// Example:
//
// > newYearsDay(2025)
// > "Wednesday"
//
// > newYearsDay(2024)
// > "Monday"
// (you can submit your answers by replying to this email with a link to your solution, or share on Bluesky, Twitter, LinkedIn, or Mastodon)
function newYearsDay(year) {
return new Date(year, 0, 1).toLocaleString(window.navigator.language, { weekday: 'long' })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment