We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home
  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 10 Days of Javascript
  4. Day 2: Loops

Day 2: Loops

Problem
Submissions
Leaderboard
Discussions
Editorial
Topics

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 a, e, i, o, 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 .

Author

AvmnuSng

Difficulty

Easy

Max Score

10

Submitted By

214364

Need Help?


View discussions
View editorial
View top submissions
RESOURCES

  • Loops

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Helpdesk
  • Careers
  • Terms Of Service
  • Privacy Policy

Cookie support is required to access HackerRank

Seems like cookies are disabled on this browser, please enable them to open this website

Join us

Create a HackerRank account

Be part of a 26 million-strong community of developers

Please signup or login in order to view this challenge

or
Already have an account?Log in