diff options
| -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}`); +}); |
