Skip to content
Advertisement

While loop to print vowels and other elements on a new line in JavaScript

Trying to print any vowels from a word on a new line in the order they appear. Then do the same for each constant after all the vowels have been printed.

I’ve tried using breaks and a switch case but the code wouldn’t work.

JavaScript

I expect an output to be like:

JavaScript

Then the consonants in the order they appear:

JavaScript

Advertisement

Answer

So here is the final code that I used. Thank for the help Dash and summit. I combined both of their codes.

JavaScript

which then get pushed up, so that it can be printed in the order they appear.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement