diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-12-08 02:58:56 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-08 02:58:56 +0000 |
| commit | f0f7b4c2c3d337a77d3be80b5d68544625b6d362 (patch) | |
| tree | dbad7a9db7b2b61839f18adfaafe8141b8f62710 /challenge-037 | |
| parent | abea03b9a914f932335c6a77dab404753b68e269 (diff) | |
| parent | 4110f65823a1d4faa31b5d030332c6f9d4955913 (diff) | |
| download | perlweeklychallenge-club-f0f7b4c2c3d337a77d3be80b5d68544625b6d362.tar.gz perlweeklychallenge-club-f0f7b4c2c3d337a77d3be80b5d68544625b6d362.tar.bz2 perlweeklychallenge-club-f0f7b4c2c3d337a77d3be80b5d68544625b6d362.zip | |
Merge pull request #1010 from mienaikage/037-1-js
Add JS solution for 037-1
Diffstat (limited to 'challenge-037')
| -rwxr-xr-x | challenge-037/daniel-mita/js/ch-1.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-037/daniel-mita/js/ch-1.js b/challenge-037/daniel-mita/js/ch-1.js new file mode 100755 index 0000000000..e71c44e9be --- /dev/null +++ b/challenge-037/daniel-mita/js/ch-1.js @@ -0,0 +1,18 @@ +const year = 2019; +const date = new Date(year, 0); +const count = new Map(); + +while (date.getFullYear() === year) { + const month = new Intl.DateTimeFormat('en-US', { month: 'long' }).format(date); + + if (!count.get(month)) count.set(month, 0); + if (date.getDay() !== 0 && date.getDay() !== 6) { + count.set(month, count.get(month) + 1); + } + + date.setDate(date.getDate() + 1); +} + +count.forEach((v, k) => { + console.log(`${k}: ${v}`); +}); |
