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.
*CompletethevowelsAndConsonantsfunction.*Printyouroutputusing'console.log()'.*/functionvowelsAndConsonants(s){constvowels=['a','e','i','o','u'];letvowelsArr=[];letconsonantArr=[];for(leti=0;i<s.length;i++){if(vowels.includes(s[i].toLowerCase())){vowelsArr.push(s[i]);}else{consonantArr.push(s[i]);}}/* Use the forEach to run through the array and print it on the console */vowelsArr.forEach(vowel=>console.log(vowel));consonantArr.forEach(consonant=>console.log(consonant));}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 2: Loops
You are viewing a single comment's thread. Return to all comments →
My answer: