In this HackerRank Day 2: Conditional Statements: Switch 10 days of javascript problem you need to Complete the getLetter(s) function in the editor. It has one parameter: a string, S, consisting of lowercase English alphabetic letters
HackerRank Day 2: Conditional Statements: Switch 10 days of javascript problem solution.
'use strict'; process.stdin.resume(); process.stdin.setEncoding('utf-8'); let inputString = ''; let currentLine = 0; process.stdin.on('data', inputStdin => { inputString += inputStdin; }); process.stdin.on('end', _ => { inputString = inputString.trim().split('n').map(string => { return string.trim(); }); main(); }); function readLine() { return inputString[currentLine++]; } function getLetter(s) { let letter; switch (true) { case 'aeiou'.includes(s[0]): letter = 'A'; break; case 'bcdfg'.includes(s[0]): letter = 'B'; break; case 'hjklm'.includes(s[0]): letter = 'C'; break; case 'npqrstvwxyz'.includes(s[0]): letter = 'D'; break; } return letter; } function main() { const s = readLine(); console.log(getLetter(s)); }