Created
March 31, 2019 03:40
-
-
Save elzup/79e5b09359db9ee566dd9ac7a8fde1cb to your computer and use it in GitHub Desktop.
Does month have 31days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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