-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06_switch.js
79 lines (73 loc) · 1.92 KB
/
06_switch.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Task
Complete the getLetter(s) function in the editor.
It has one parameter: a string, s, consisting of lowercase English alphabetic letters (i.e., a through z).
It must return A, B, C, or D depending on the following criteria:
If the first character in string s is in the set {a,e,i,0,u}, then return A.
If the first character in string s is in the set {b,c,d,f,g}, then return B.
If the first character in string s is in the set {h,j,k,l,m}, then return C.
If the first character in string s is in the set {n,p,q,r,s,t,u,v,w,x,y,z}, then return D.
Hint: You can get the letter at some index in using the syntax s[i] or s.charAt(i). */
function getLetterr(s) {
switch(s[0]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return 'A';
case 'b':
case 'c':
case 'd':
case 'f':
case 'g':
return 'B';
case 'h':
case 'j':
case 'k':
case 'l':
case 'm':
return 'C';
default:
return 'D';
}
}
function getLetterr(s) {
let letter;
// Write your code here
switch(s[0]){
case ("a"||"e"||"i"||"o"||"u"):
letter="A";
break;
case ("b"||"c"||"d"||"f"||"g"):
letter="B";
break;
case ('h'||"j"||"k"||"l"||"m"):
letter="C";
break;
default:
letter="D";
}
return letter;
}
function getLetterrr(s){
let letter;
var set1 = new Set(['a','e','i','o','u']);
var set2 = new Set(['b','c','d','f','g']);
var set3 = new Set(['h','j','k','l','m']);
switch(s!==''){
case set1.has(s[0]):
letter ="A";
break;
case set2.has(s[0]):
letter ="B";
break;
case set3.has(s[0]):
letter="C";
break;
default:
letter="D";
}
return letter;
}
console.log(getLetter("sss"));