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 
		

Leave a Comment

Scroll to Top