Day 2: Loops in Javascript | 10 Days Of JavaScript Solutions | HackerRank Programming Solutions [💯Correct]

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank, 10 Days Of JavaScript. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Day 2: Loops in JavaScript-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To JavaScript

JavaScript is a lightweight, cross-platform, and interpreted scripting language. It is well-known for the development of web pages, many non-browser environments also use it. JavaScript can be used for Client-side developments as well as Server-side developments. JavaScript contains a standard library of objects, like Array, Date, and Math, and a core set of language elements like operators, control structures, and statements.

Advantages of JavaScript

The merits of using JavaScript are −

  • Less server interaction − You can validate user input before sending the page off to the server. This saves server traffic, which means less load on your server.
  • Immediate feedback to the visitors − They don’t have to wait for a page reload to see if they have forgotten to enter something.
  • Increased interactivity − You can create interfaces that react when the user hovers over them with a mouse or activates them via the keyboard.
  • Richer interfaces − You can use JavaScript to include such items as drag-and-drop components and sliders to give a Rich Interface to your site visitors.

Link for the ProblemDay 2: Loops – Hacker Rank Solution

Day 2: Loops – Hacker Rank Solution

Problem:

Objective

In this challenge, we practice looping over the characters of string. Check out the attached tutorial for more details.

Task

  1. First, print each vowel in  on a new line. The English vowels are aeio, and u, and each vowel must be printed in the same order as it appeared in .
  2. Second, print each consonant (i.e., non-vowel) in  on a new line in the same order as it appeared in .

Function Description

Complete the vowelsAndConsonants function in the editor below.

vowelsAndConsonants has the following parameters:

  • string s: the string to process

Prints

  • Print each vowel of  in order on a new line, then print each consonant in order on a new line. Return nothing.

Input Format

There is one line of input with the string .

Output Format

First, print each vowel in  on a new line (in the same order as they appeared in ). Second, print each consonant (i.e., non-vowel) in  on a new line (in the same order as they appeared in ).

Sample Input 0

javascriptloops

Sample Output 0

a
a
i
o
o
j
v
s
c
r
p
t
l
p
s

Explanation 0

Observe the following:

  • Each letter is printed on a new line.
  • Then the vowels are printed in the same order as they appeared in .
  • Then the consonants are printed in the same order as they appeared in .
Day 2: Loops – Hacker Rank Solution
function vowelsAndConsonants(s) {
  const vowels = ["a", "e", "i", "o", "u"];
  const string = s.split("");
  let vowelArr = [];
  let consonantArr = [];
  for (let i = 0; i < string.length; i++) {
    vowels.includes(string[i])
      ? vowelArr.push(string[i])
      : consonantArr.push(string[i]);
  }
  for (let i = 0; i < vowelArr.length; i++) {
    console.log(vowelArr[i]);
  }
  for (let i = 0; i < consonantArr.length; i++) {
    console.log(consonantArr[i]);
  }
}

141 thoughts on “Day 2: Loops in Javascript | 10 Days Of JavaScript Solutions | HackerRank Programming Solutions [💯Correct]”

  1. That is very attention-grabbing, You’re a very professional blogger.
    I have joined your rss feed and look forward to in search of more of your magnificent post.
    Additionally, I have shared your web site in my social networks

    Reply
  2. Everyone loves what you guys are usually up too.
    This sort of clever work and exposure! Keep up the excellent works guys I’ve incorporated you
    guys to my own blogroll.

    Reply
  3. I absolutely love your blog and find many of your post’s to be exactly what I’m looking for.
    Do you offer guest writers to write content available for
    you? I wouldn’t mind producing a post or
    elaborating on some of the subjects you write about here. Again, awesome
    weblog!

    Reply
  4. I’m truly enjoying the design and layout of your website. It’s a very
    easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme?
    Great work!

    Reply
  5. Great post. I was checking constantly this blog and I’m inspired!
    Very useful information specifically the last part 🙂 I deal with such info much.
    I was seeking this certain information for a long time.
    Thanks and good luck.

    Reply
  6. Fascinating blog! Is your theme custom made or did you download it from somewhere?
    A theme like yours with a few simple tweeks would really make
    my blog jump out. Please let me know where you got your design. Kudos

    Reply
  7. Can I show my graceful appreciation and show my hidden information on really good stuff and if you want to really
    findout? Let me tell you a brief about how to make passive income I am always here for yall you know that right?

    Reply
  8. I am extremely inspired together with your
    writing talents and also with the layout on your
    blog. Is this a paid subject or did you modify it yourself?
    Either way stay up the nice quality writing, it’s uncommon to
    peer a nice weblog like this one today..

    Reply
  9. I’m not sure exactly why but this web site is loading extremely slow for me.
    Is anyone else having this issue or is it a issue
    on my end? I’ll check back later on and see if the
    problem still exists.

    Reply
  10. You really make it seem so easy with your presentation but
    I to find this matter to be really something which I think I’d never
    understand. It sort of feels too complicated and extremely vast for me.
    I am taking a look forward on your subsequent publish, I will try to get the hang of it!

    Reply
  11. My programmer is trying to persuade me to move to .net from PHP.

    I have always disliked the idea because of the expenses.

    But he’s tryiong none the less. I’ve been using WordPress on various websites for about a year and am anxious
    about switching to another platform. I have heard excellent things about blogengine.net.
    Is there a way I can transfer all my wordpress posts into it?

    Any kind of help would be greatly appreciated!

    Reply
  12. I’m really enjoying the design and layout of your site.

    It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme?
    Great work!

    Reply
  13. Simply desire to say your article is as astonishing.
    The clearness in your post is just cool and that i can assume you’re a
    professional in this subject. Well with your permission let me to grab your RSS feed to stay updated with impending post.
    Thanks a million and please continue the rewarding work.

    Reply
  14. I believe people who wrote this needs true loving because it’s
    a blessing. So let me give back and give my value on change your life and if you want to seriously get
    to hear I will share info about how to change your life Don’t forget..
    I am always here for yall. Bless yall!

    Reply
  15. Hello there! Would you mind if I share your blog with my zynga group?

    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Many thanks

    Reply
  16. Hi there! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on.
    Any recommendations?

    Reply
  17. Wow, fantastic weblog structure! How long have you ever been running a blog for?
    you make blogging glance easy. The full look of your website
    is excellent, let alone the content material!

    Reply
  18. Wonderful beat ! I would like to apprentice whilst you amend your website, how could i subscribe for a blog site?
    The account aided me a appropriate deal. I had been tiny bit acquainted of
    this your broadcast provided vibrant transparent idea

    Reply
  19. I’ve been surfing online more than 2 hours today,
    yet I never found any interesting article like yours.
    It is pretty worth enough for me. In my opinion, if all site owners and
    bloggers made good content as you did, the net will be a lot more useful than ever
    before.

    Reply
  20. Cool blog! Is your theme custom made or did you download
    it from somewhere? A design like yours with a few simple
    adjustements would really make my blog shine. Please let me know where you
    got your theme. Appreciate it

    Reply
  21. OMG! This is amazing. Ireally appreciate it~ May
    I tell you my secret ways on a secret only I KNOW and if you want to seriously get to hear You really have to
    believe mme and have faith and I will show how to find good hackers for good price Once again I want to show my
    appreciation and may all the blessing goes to you now!.

    Reply
  22. Hey There. I found your weblog the use of msn. That is a very smartly written article.
    I will be sure to bookmark it and come back to learn more of your useful information. Thank you
    for the post. I will definitely return.

    Reply

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker🙏.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock