In this HackerRank Day 2: conditional statements: days of javascript problem solution 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,o,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,v,w,x,y,z}, then return D.


HackerRank Day 2: Conditional Statements: Switch problem solution


Problem solution in JavaScript programming.

function getLetter(s) {
    let letter;
    // Write your code here
    switch(true) {
        case ('aeiou'.includes(s[0])):       
            return "A";
        case ("bcdfg".includes(s[0])):
            return "B";
        case ("hjklm".includes(s[0])):
            return "C";
        case ("npqrstvwxyz".includes(s[0])):
            return "D";
            
    }
        
    
   
    return "";
}