-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmonthName.js
52 lines (50 loc) · 1.02 KB
/
monthName.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Create a function that takes a number (from 1 to 12) and returns its corresponding month name as a string. For example,
// if you're given 3 as input, your function should return "March", because March is the 3rd month.
// Examples:
// monthName(3) ➞ "March"
// monthName(12) ➞ "December"
// monthName(6) ➞ "June"
function monthName(num) {
switch (num) {
case 1:
return "January";
break;
case 2:
return "February";
break;
case 3:
return "March";
return;
break;
case 4:
return "April";
break;
case 5:
return "May";
break;
case 6:
return "June";
break;
case 7:
return "July";
break;
case 8:
return "August";
break;
case 9:
return "September";
break;
case 10:
return "October";
break;
case 11:
return "November";
break;
case 12:
return "December";
break;
default:
return `The input is wrong!`;
}
}
console.log(monthName(3));