Skip to content

Instantly share code, notes, and snippets.

@elzup
Created March 31, 2019 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elzup/e4415065a5ca144adf267609c35c5f82 to your computer and use it in GitHub Desktop.
Save elzup/e4415065a5ca144adf267609c35c5f82 to your computer and use it in GitHub Desktop.
const has31 = month => Boolean((month & 1) ^ ((month >> 3) & 1))
test('1-12', () => {
expect(has31(1)).toMatchInlineSnapshot(`true`)
expect(has31(2)).toMatchInlineSnapshot(`false`)
expect(has31(3)).toMatchInlineSnapshot(`true`)
expect(has31(4)).toMatchInlineSnapshot(`false`)
expect(has31(5)).toMatchInlineSnapshot(`true`)
expect(has31(6)).toMatchInlineSnapshot(`false`)
expect(has31(7)).toMatchInlineSnapshot(`true`)
expect(has31(8)).toMatchInlineSnapshot(`true`)
expect(has31(9)).toMatchInlineSnapshot(`false`)
expect(has31(10)).toMatchInlineSnapshot(`true`)
expect(has31(11)).toMatchInlineSnapshot(`false`)
expect(has31(12)).toMatchInlineSnapshot(`true`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment