Skip to content

Commit 5633872

Browse files
committed
solutions added
1 parent 6286abf commit 5633872

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

solutions/javascript-test-2020.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -126,23 +126,27 @@ console.log('==================== BEGIN Q3 ============================ ')
126126

127127
// 3. 1
128128
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)
132135
const month = firstLetter + remainingStr
133136

134137
let statement
135-
switch (m) {
138+
let days
139+
switch (userInput) {
136140
case 'february':
137-
day = 28
138-
statement = `${month} has ${day}.`
141+
days = 28
142+
statement = `${month} has ${days} days.`
139143
break
140144
case 'april':
141145
case 'june':
142146
case 'september':
143147
case 'november':
144-
day = 30
145-
statement = `${month} has ${day}.`
148+
days = 30
149+
statement = `${month} has ${days} days.`
146150
break
147151
case 'january':
148152
case 'march':
@@ -151,8 +155,8 @@ const howManyDaysInMonth = () => {
151155
case 'august':
152156
case 'october':
153157
case 'december':
154-
day = 31
155-
statement = `${month} has ${day}.`
158+
days = 31
159+
statement = `${month} has ${days} days.`
156160
break
157161
default:
158162
return 'The given value is not a month'
@@ -626,7 +630,6 @@ const mostSpokenLanguages = async (n = 10) => {
626630

627631
console.log('Most spoken languages', mostSpokenLanguages(15))
628632

629-
630633
// 8.2
631634

632635
const add = (a, b) => {

0 commit comments

Comments
 (0)