File tree 1 file changed +14
-11
lines changed
1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -126,23 +126,27 @@ console.log('==================== BEGIN Q3 ============================ ')
126
126
127
127
// 3. 1
128
128
const howManyDaysInMonth = ( ) => {
129
- const m = prompt ( 'Enter month' ) . toLowerCase ( )
130
- const firstLetter = m [ 0 ] . toUpperCase ( )
131
- const remainingStr = m . slice ( 1 )
129
+ const userInput = prompt ( 'Enter a month: ' )
130
+ . trim ( )
131
+ . toLowerCase ( )
132
+
133
+ const firstLetter = userInput [ 0 ] . toUpperCase ( )
134
+ const remainingStr = userInput . slice ( 1 )
132
135
const month = firstLetter + remainingStr
133
136
134
137
let statement
135
- switch ( m ) {
138
+ let days
139
+ switch ( userInput ) {
136
140
case 'february' :
137
- day = 28
138
- statement = `${ month } has ${ day } .`
141
+ days = 28
142
+ statement = `${ month } has ${ days } days .`
139
143
break
140
144
case 'april' :
141
145
case 'june' :
142
146
case 'september' :
143
147
case 'november' :
144
- day = 30
145
- statement = `${ month } has ${ day } .`
148
+ days = 30
149
+ statement = `${ month } has ${ days } days .`
146
150
break
147
151
case 'january' :
148
152
case 'march' :
@@ -151,8 +155,8 @@ const howManyDaysInMonth = () => {
151
155
case 'august' :
152
156
case 'october' :
153
157
case 'december' :
154
- day = 31
155
- statement = `${ month } has ${ day } .`
158
+ days = 31
159
+ statement = `${ month } has ${ days } days .`
156
160
break
157
161
default :
158
162
return 'The given value is not a month'
@@ -626,7 +630,6 @@ const mostSpokenLanguages = async (n = 10) => {
626
630
627
631
console . log ( 'Most spoken languages' , mostSpokenLanguages ( 15 ) )
628
632
629
-
630
633
// 8.2
631
634
632
635
const add = ( a , b ) => {
You can’t perform that action at this time.
0 commit comments