Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript loop over the alphabet and return the vowels

function vowelsAndConsonants(s) {
//Create Array of vowels
   const vowels = ["a","e","i","o","u"];
//Convert String to Array
   const arr = s.split("");
//Empty vowels and cons array
   var vowelsFound = [];
   var cons = [];
//Push vowels and cons to their arrays
   for (var i in arr) {
     if (vowels.includes(arr[i])) {
        vowelsFound.push(arr[i]);
        } else {
            cons.push(arr[i]);
        }
   }
//ConsoleLog so that they in order and cons follows vowels on new lines
   console.log(vowelsFound.join('
') + '
' + cons.join('
'))
}
//Test, Exclude in copy
vowelsAndConsonants(javascriptloops); 
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery fade out 
Javascript :: javascript dir 
Javascript :: javascript queryselector child element 
Javascript :: how to autoload config files added in composer.json laravel 
Javascript :: js create json array 
Javascript :: number round 
Javascript :: how to delete file from firebase storage on web 
Javascript :: finding an element ina na array in js 
Javascript :: how to check value is array or not in javascript 
Javascript :: e.target.text react 
Javascript :: http to https express js 
Javascript :: how to filter out undefined keys from object in js 
Javascript :: moment get start of week in datetime 
Javascript :: js Float32Array to percentage 
Javascript :: toggle boolean js 
Javascript :: jquery show password 
Javascript :: include other js files in a js file 
Javascript :: javascript canvas to image 
Javascript :: json limit nodejs 
Javascript :: clean url javascript 
Javascript :: javascript urlsearchparams to string 
Javascript :: remove item at index in array javascript 
Javascript :: foreach over array javascript 
Javascript :: get object with max value javascript 
Javascript :: find last element in array nodejs 
Javascript :: jquery set textbox value 
Javascript :: change root color js 
Javascript :: how to capitalize first letter in javascript 
Javascript :: javascript check if object 
Javascript :: delete node module 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =