HackerRank Solution

Day 2: Conditional Statements: Switch| HackerRank solution.

Hello programmers, today we are sharing proper solutions with all test cases passed on 10 Days of JavaScript by HackerRank.

As you all know JavaScript is the most popular and most challenging programming language to conquer but nowadays it’s not. There are some amazing platforms where that provide challenges in different languages and HackerRank is one of them.

In this challenge, we learn about switch statements. 

Before checking out the solution it’s highly recommended to do it by yourself first because these challenges will help you to think about how to deal with these real-world problems.

Let’s get started.

Here are a couple of related posts you may find helpful, too:

  1. Day 0: Hello, World! in Javascript| HackerRank Solutions
  2. Day 0: Data Types HackerRank Solution| Amazing 10 Days of JavaScript
  3. How to make money through coding? 9 Easy Ways To Make Money.
  4. 15+FREE Stuff For College Students Using Your College ID.
  5. how to get rich by coding? I make $100 every month from coding

Problem: If-Else in JavaScript

HackerRank solution

Overview: 10 Days of JavaScript| HackerRank Solution

function getLetter(s) {
    let letter;
    // Write your code here
        switch(s.charAt(0)){
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
        letter= 'A';
        break;
        
        case 'b':
        case 'c':
        case 'd':
        case 'f':
        case 'g':
        letter= 'B';
        break;
        
        case 'h':
        case 'k':
        case 'k':
        case 'l':
        case 'm':
        letter= 'C';
        break;
        
        case 'n':
        case 'p':
        case 'q':
        case 'r':
        case 's':
        case 't':
        case 'v':
        case 'w':
        case 'x':
        case 'y':
        case 'z':
        letter= 'D';
        break;    
    }
    return letter;
}

If you’d like to see some more articles, be sure to read more blogs so you can keep up to date with the latest design tutorials and tricks.

To contact me here’s my Instagram link: untied_blog

Read more

  1. how to get rich by coding? I make $100 every month from coding
  2. How To Create An App Without Coding| Build an App In 5 Minutes
  3. 11 Amazing ReactJS Projects Ideas For Beginners with Source Code
  4. How To Answer “Tell Me About Yourself”| Interview Questions.
  5. How To Answer “Strengths And Weaknesses” (Interview Questions)
  6. “Why Should We Hire You” 7+ Best Answers Examples

Leave a Comment