10 Days Of JavaScript
  • 10 Days Of JS
  • INDEX
    • Day 0: Hello, World!
    • Day 0: Data Types
    • Day 1: Arithmetic Operators
    • Day 1: Functions
    • Day 1: Let and Const
    • Day 2: Conditional Statements: If-Else
    • Day 2: Conditional Statements: Switch
    • Day 2: Loops
    • Day 3: Arrays
    • Day 3: Try, Catch, and Finally
    • Day 3: Throw
    • Day 4: Create a Rectangle Object
    • Day 4: Count Objects
    • Day 4: Classes
    • Day 5: Inheritance
    • Day 5: Template Literals
    • Day 5: Arrow Functions
    • Day 6: Bitwise Operators
    • Day 6: JavaScript Dates
    • Day 7: Regular Expressions I
    • Day 7: Regular Expressions II
    • Day 7: Regular Expressions III
    • Day 8: Create a Button
    • Day 8: Buttons Container
    • Day 9: Binary Calculator
Powered by GitBook
On this page
  • Problem Link
  • Solution

Was this helpful?

  1. INDEX

Day 2: Loops

PreviousDay 2: Conditional Statements: SwitchNextDay 3: Arrays

Last updated 3 years ago

Was this helpful?

Problem Link

Solution

loops.js
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]);
  }
HackerRank Problem Link