MCPcopy
hub / github.com/TheAlgorithms/JavaScript / printCal

Method printCal

Dynamic-Programming/FindMonthCalendar.js:17–38  ·  view source on GitHub ↗
(days, startDay, output = (value) => console.log(value))

Source from the content-addressed store, hash-verified

15 }
16
17 printCal(days, startDay, output = (value) => console.log(value)) {
18 output('M T W Th F S Su')
19 const dates = []
20 let i
21 for (i = 1; i <= days; i++) {
22 dates.push(i)
23 }
24 for (i = 0; i < this.Days.indexOf(startDay); i++) {
25 dates.unshift(' ')
26 }
27 while (true) {
28 let row = ''
29 for (i = 0; i < 7 && dates.length !== 0; i++) {
30 row += dates.shift()
31 while (row.length % 4 !== 0) {
32 row += ' '
33 }
34 }
35 output(row)
36 if (dates.length === 0) break
37 }
38 }
39
40 parseDate(date) {
41 const dateAr = []

Callers 1

generateMonthCalMethod · 0.95

Calls 4

outputFunction · 0.85
logMethod · 0.45
pushMethod · 0.45
indexOfMethod · 0.45

Tested by

no test coverage detected